code: public void destroy() {
          // if we are in init state then switch to destroy, this will do nothing if this is unsafe
          monitorState.compareAndSet(MonitorState.INIT.ordinal(), MonitorState.DESTROY.ordinal());
          // indicate monitor should be destroyed.
          if (monitorState.compareAndSet(MonitorState.ACTIVE.ordinal(), MonitorState.DESTROY.ordinal())) {
              // Stop the scheduled scan task
              stop();
  
              // attempt to really destroy: may "fail" if lock cannot be obtained
              doDestroy();
          }
      }
docs: Called when a service is unregistered or replaced because the
  bundle that created/registered the ServiceReference is stopping
  (unless the framework itself is also stopping, in which
  case {@link #stop()} will be called instead.
  
  Resources should be cleaned up, future cancelled, etc.