Fix race condition where websocket closed error is shown

re: #53