websocket_client: Fix problem when remote end disconnects