code: private void destroyEndpointMBeans() {
          for (Map.Entry<String, ServiceRegistration<DynamicMBean>> mbean : endpointMBeans.entrySet()) {
              String mbeanName = mbean.getKey();
              endpointMBeans.remove(mbeanName);
              mbean.getValue().unregister();
          }
      }
docs: For each registered MBean, unpublish, unregister and remove from the map.