code: void closeSocket(boolean tryReconnectIfConnected) throws InterruptedException {
          boolean wasConnected = false;
  
          statusLock.lock();
          try {
              if (isDisconnectingOrClosed()) {
                  waitForDisconnectOrClose(this.options.getConnectionTimeout());
                  return;
              } else {
                  this.disconnecting = true;
                  this.exceptionDuringConnectChange = null;
                  wasConnected = (this.status == Status.CONNECTED);
                  statusChanged.signalAll();
              }
          } finally {
              statusLock.unlock();
          }
  
          closeSocketImpl();
  
          statusLock.lock();
          try {
              updateStatus(Status.DISCONNECTED);
              this.exceptionDuringConnectChange = null; // Ignore IOExceptions during closeSocketImpl()
              this.disconnecting = false;
              statusChanged.signalAll();
          } finally {
              statusLock.unlock();
          }
  
          if (isClosing()) { // Bit of a misname, but closing means we are in the close method or were asked
                             // to be
              close();
          } else if (wasConnected && tryReconnectIfConnected) {
              reconnect();
          }
      }
docs: Close is called when the connection should shutdown, period