Handle socket close in websocket_receive correctly