fixed websocket client socket not being closed in some cases and server
waiting for clients to close connection first