Fix crash when websocket  close by server side. Send an error message when connect to a closed server.
Waiting for the subThread safety exit.