code: public void close() {
          if (closed) {
              log.debug("Already closed, nothing to do");
              return;
          }
          closed = true;
          if (scope != null) {
              log.debug("Close, disconnect from scope, and children");
              try {
                  // unregister all child scopes first
                  for (IBasicScope basicScope : basicScopes) {
                      unregisterBasicScope(basicScope);
                  }
              } catch (Exception err) {
                  log.error("Error while unregistering basic scopes", err);
              }
              // disconnect
              if (scope != null) {
                  try {
                      scope.disconnect(this);
                  } catch (Exception err) {
                      log.error("Error while disconnecting from scope: {}. {}", scope, err);
                  }
                  scope = null;
              }
          }
          // unregister client
          if (client != null && client instanceof Client) {
              ((Client) client).unregister(this);
          }
          // alert our listeners
          if (connectionListeners != null) {
              for (IConnectionListener listener : connectionListeners) {
                  listener.notifyDisconnected(this);
              }
              connectionListeners.clear();
              connectionListeners = null;
          }
      }
docs: Closes connection