code: public void disconnect(){
          if(timer != null){
              timer.cancel();
          }
          if (ws != null && ws.isOpen()) {
              ws.disconnect();
              subscribedTokens = new HashSet<>();
              modeMap.clear();
          }
      }
docs: Disconnects websocket connection.