@Override
    public synchronized void shutdown() {
        if (monitoring) {
            try {
                stop();
            } catch (Exception e) {
                LOG.warn("Error stopping the metrics system", e);
            }
        }
        MBeans.unregister(mbeanName);
    }