Better error handling on connect

This should handle cases of disconnecting when the connection is still being established.