private void stopRMIConnectorServer() {
    if (!agentConfig.isRmiEnabled()) {
      return;
    }

    // stop the RMI Connector server...
    try {
      rmiConnector.stop();
    } catch (Exception e) {
      logger.warn(e.getMessage(), e);
    }

    try {
      ObjectName rmiRegistryNamingName = getRMIRegistryNamingName();
      if (agentConfig.isRmiRegistryEnabled()
          && mBeanServer.isRegistered(rmiRegistryNamingName)) {
        String[] empty = new String[0];
        mBeanServer.invoke(rmiRegistryNamingName, "stop", empty, empty);
        MBeanUtils.unregisterMBean(rmiRegistryNamingName);
      }
    } catch (MalformedObjectNameException e) {
      logger.warn(e.getMessage(), e);
    } catch (InstanceNotFoundException e) {
      logger.warn(e.getMessage(), e);
    } catch (ReflectionException e) {
      logger.warn(e.getMessage(), e);
    } catch (MBeanException e) {
      logger.warn(e.getMessage(), e);
    }

    try {
      ObjectName rmiConnectorServerName = getRMIConnectorServerName();
      if (mBeanServer.isRegistered(rmiConnectorServerName)) {
        MBeanUtils.unregisterMBean(rmiConnectorServerName);
      }
    } catch (MalformedObjectNameException e) {
      logger.warn(e.getMessage(), e);
    }
  }
Stops the RMIConnectorServer and unregisters its MBean.
geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentImpl.java