improved handling of WebSocket connection closes