Closing of listening port

More error catching