code: public synchronized void unregister() throws Exception {
          if (mbeanName == null) {
              throw new Exception("Agent not registered");
          }
          logger.info("Unregistering JMX agent " + mbeanName);
          ManagementFactory.getPlatformMBeanServer().unregisterMBean(mbeanName);
          logger.info("JMX agent " + mbeanName + " unregistered");
      }
docs: Unregister the JMX agent