Find out which PID listens on socket
Show all sockets (Unix & TCP/UDP), both listening and established ones:
netstat -anp
To limit the output e.g. to listening TCP sockets:
netstat -anp | grep tcp | grep LISTEN
...
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 28683/server
...
This means: A tcp v4 socket listening on port 3000 on all IP adresses (0.0.0.0 is synonym to 'all interfaces on the machine').
The last column includes the PID, kill -9 28683
should exit the process and clean up the socket.