Closing an open port via Mac's terminal
Use below command in terminal to get a list of all open ports:
netstat -an | grep LISTEN
Find the process ID (PID) of the port you wish to close. You may need to use sudo.
lsof -i :[portNumber]
Then use the following command to kill the process listening on your port. You may need to use sudo with kill -9 parameter.
kill [PID]