small change in the logic when websocket is closed