websocket close function repair