code: public void cleanup() {
          cleanupLock.lock();
          try {
              // Clean up the write interface.
              if (null != writeInterface) {
                  this.writeInterface.close();
                  this.writeInterface = null;
              }
              // Clean up the read interface.
              if (null != readInterface) {
                  this.readInterface.close();
                  this.readInterface = null;
              }
              // Clean up the SSL engine.
              if (null != getSSLEngine()) {
                  //If the channel has already processed the stop signal, it is too late to try and send the write handshake
                  if (this.sslChannel.getstop0Called() == true) {
                      this.connected = false;
                  }
  
                  SSLUtils.shutDownSSLEngine(this, isInbound, this.connected);
  
                  this.sslEngine = null;
              }
              // mark that we have disconnected
              this.connected = false;
          } finally {
              cleanupLock.unlock();
          }
      }
docs: This method is called from both close and destroy to clean up local resources.
  Avoid object synchronization, but ensure only one thread does cleanup at a time.