@Override
  public boolean disconnect() {
    boolean disconnectedTrue;
    synchronized (this) {
      if (disconnected) {
        return false;
      }
      disconnected = true;
      disconnectedTrue = true;
    }
    try {
      listening = false;
      joinProcessor.shutDown();
      boolean removeListener = alertLevel != Alert.OFF;
      if (isConnected() || !membersMap.isEmpty()) {
        RemoteApplicationVM[] apps = (RemoteApplicationVM[]) listApplications(disconnectedTrue);
        for (RemoteApplicationVM app : apps) {
          try {
            app.disconnect(removeListener);
            // hit NPE here in ConsoleDistributionManagerTest so
            // fixed listApplications to exclude nulls returned from future
          } catch (RuntimeException ignore) {
            // if we can't notify a member that we are disconnecting don't throw
            // an exception. We need to finish disconnecting other resources.
          }
        }
        try {
          DistributionManager dm = system.getDistributionManager();
          synchronized (myMembershipListenerLock) {
            if (myMembershipListener != null) {
              dm.removeMembershipListener(myMembershipListener);
            }
          }

          if (dm instanceof ClusterDistributionManager) {
            ((ClusterDistributionManager) dm).setAgent(null);
          }

        } catch (IllegalArgumentException ignore) {
          // this can happen when connectToDS has not yet done the add

        } catch (DistributedSystemDisconnectedException de) {
          // ignore a forced disconnect and finish clean-up
        }

        synchronized (systemLock) {
          if (system != null
              && ClusterDistributionManager.isDedicatedAdminVM()
              && system.isConnected()) {
            system.disconnect();
          }
          system = null;
        }
        connected = false;
      }

      daemon.shutDown();

      if (snapshotDispatcher != null) {
        snapshotDispatcher.shutDown();
      }
    } finally {
      removeAgent(this);
    }
    return true;
  }
Disconnects this agent from the distributed system. If this is a dedicated administration VM,
then the underlying connection to the distributed system is also closed.

@return true if this agent was disconnected as a result of the invocation
@see RemoteGemFireVM#disconnect
geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteGfManagerAgent.java