If you use linux you can use lsof to find out which process is using a given port, you might have to install it first though, usage is pretty simple:
lsof -i :5000
To kill the python process which is listening on port 5000 :
sudo lsof -i :5000 | grep "python" | cut -d " " -f3 | xargs kill -9
You're probably closing the server using Ctrl-Z. If so, use Ctrl-C instead.