docs: @Override
      public synchronized BeanContext stop() {
          if (terminating.compareAndSet(false, true)) {
              if (LOG.isDebugEnabled()) {
                  LOG.debug("Stopping BeanContext");
              }
              publishEvent(new ShutdownEvent(this));
  
              // need to sort registered singletons so that beans with that require other beans appear first
              List<BeanRegistration> objects = topologicalSort(singletonObjects.values());
  
              Set<Integer> processed = new HashSet<>();
              for (BeanRegistration beanRegistration : objects) {
                  BeanDefinition def = beanRegistration.beanDefinition;
                  Object bean = beanRegistration.bean;
                  int sysId = System.identityHashCode(bean);
                  if (processed.contains(sysId)) {
                      continue;
                  }
  
                  if (LOG_LIFECYCLE.isDebugEnabled()) {
                      LOG_LIFECYCLE.debug("Destroying bean [{}] with identifier [{}]", bean, beanRegistration.identifier);
                  }
  
                  processed.add(sysId);
                  if (def instanceof DisposableBeanDefinition) {
                      try {
                          //noinspection unchecked
                          ((DisposableBeanDefinition) def).dispose(this, bean);
                      } catch (Throwable e) {
                          if (LOG.isErrorEnabled()) {
                              LOG.error("Error disposing of bean registration [" + def.getName() + "]: " + e.getMessage(), e);
                          }
                      }
                  }
                  if (def instanceof Closeable) {
                      try {
                          ((Closeable) def).close();
                      } catch (Throwable e) {
                          if (LOG.isErrorEnabled()) {
                              LOG.error("Error disposing of bean registration [" + def.getName() + "]: " + e.getMessage(), e);
                          }
                      }
                  }
                  if (bean instanceof LifeCycle) {
                      ((LifeCycle) bean).stop();
                  }
              }
  
              terminating.set(false);
              running.set(false);
              ClassLoadingReporter.finish();
          }
          return this;
      }