How do I close an open port from the terminal on the Mac?
#Find out the process ID (PID) which is occupying the port number (e.g., 5955) you would like to free
sudo lsof -i :5955
#Kill the process which is currently using the port using its PID
sudo kill -9 PID