Close socket when connection might be in a bad state

Rather than trying to recover from any number of network problems, close
the socket as a signal to the user to reconnect.