close websocket connection in beforeunload