code: public void close() {
          if (connected.compareAndSet(true, false)) {
              // remove handshake flag
              session.removeAttribute(Constants.HANDSHAKE_COMPLETE);
              // clear the delay queue
              queue.clear();
              // whether to attempt a nice close or a forceful one
              if (WebSocketTransport.isNiceClose()) {
                  // send a proper ws close
                  Packet packet = Packet.build(Constants.CLOSE_MESSAGE_BYTES, MessageType.CLOSE);
                  WriteFuture writeFuture = session.write(packet);
                  writeFuture.addListener(new IoFutureListener<WriteFuture>() {
  
                      @Override
                      public void operationComplete(WriteFuture future) {
                          if (future.isWritten()) {
                              log.debug("Close message written");
                              // only set on success for now to skip boolean check later
                              session.setAttribute(Constants.STATUS_CLOSE_WRITTEN, Boolean.TRUE);
                          }
                          future.removeListener(this);
                      }
  
                  });
                  // adjust close routine to allow for flushing
                  CloseFuture closeFuture = session.closeOnFlush();
                  closeFuture.addListener(new IoFutureListener<CloseFuture>() {
  
                      public void operationComplete(CloseFuture future) {
                          if (future.isClosed()) {
                              log.debug("Connection is closed");
                          } else {
                              log.debug("Connection is not yet closed");
                          }
                          future.removeListener(this);
                      }
  
                  });
              } else {
                  // force close
                  CloseFuture closeFuture = session.closeNow();
                  closeFuture.addListener(new IoFutureListener<CloseFuture>() {
  
                      public void operationComplete(CloseFuture future) {
                          if (future.isClosed()) {
                              log.debug("Connection is closed");
                          } else {
                              log.debug("Connection is not yet closed");
                          }
                          future.removeListener(this);
                      }
  
                  });
              }
          }
      }
docs: close Connection