code: public static void unregisterMbean(MBeanServer server, ObjectName name) {
          try {
              server.unregisterMBean(name);
          } catch(Exception e) {
              logger.error("Error unregistering mbean", e);
          }
      }
docs: Unregister the mbean with the given name
  
  @param server The server to unregister from
  @param name The name of the mbean to unregister