how to close all ports on mac code example
Example 1: kill port mac terminal
sudo lsof -i <Port>
sudo kill -9 <PID>
Example 2: release a port in mac
sudo lsof -i :<port>
sudo lsof -i <Port>
sudo kill -9 <PID>
sudo lsof -i :<port>