disconnect websocket properly when switching to another page