Fixes crash due SocketException when restarting