public void stop() throws IOException {
    if (started) {
      if (isAuthorized) {
        this.logout();
      }
      if (connection != null) {
        CloseConnectionMessage closeConnectionMessage = new CloseConnectionMessage();
        sendMessageToServer(closeConnectionMessage);
        outputThread.interrupt();
      }
    }
  }