Destroy (nullify) the chain of loggers references, also closing resources when needed.

@since Moodle 3.1
422460
public final function destroy() {
        // Recursively destroy the chain.
        if ($this->next !== null) {
            $this->next->destroy();
            $this->next = null;
        }
        // And close every logger.
        $this->close();
    }
273467
@Invalidate
    void shutdown() {
        if (repository != null) {
            repository.dispose();
        }

        if (emRegistration != null) {
            emRegistration.unregister();
        }
        if (entityManager != null) {
            entityManager.close();
        }
        if (emfRegistration != null) {
            emfRegistration.unregister();
        }
        if (entityManagerFactory != null) {
            entityManagerFactory.close();
        }
        if (transformer != null) {
            transformer.unregister(sourceBundle.bundle);
        }
    }
80903
@Override
  public void destroy()
  {
    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();
    
    try {
      thread.setContextClassLoader(this);
      
      WeakStopListener stopListener = _stopListener;
      _stopListener = null;

      super.destroy();
      
      thread.setContextClassLoader(oldLoader);

      ClassLoader parent = getParent();
      for (; parent != null; parent = parent.getParent()) {
        if (parent instanceof EnvironmentClassLoader) {
          EnvironmentClassLoader loader = (EnvironmentClassLoader) parent;

          loader.removeListener(stopListener);
        }
      }
    } finally {
      thread.setContextClassLoader(oldLoader);
      
      //_owner = null;
      _attributes = null;
      _listeners = null;
      //_scanListeners = null;
      //_stopListener = null;

      /*
      EnvironmentAdmin admin = _admin;
      _admin = null;

      if (admin != null)
        admin.unregister();
        */
    }
  }
397194
public void destroy()
	{
		mom.cleanUp();
		mThread.stop();
		si = null;
		mom = null;
		cache = null;
		mThread = null;
	}
1368863
public function destroy()
    {
        // This is not mandatory as GC will free the memory eventually but allows memory to be freed faster
        // by removing circular dependencies.
        if (!empty($this->data)) {
            foreach ($this->data as $data) {
                if ($data instanceof DestroyableObject) {
                    $data->destroy();
                }
            }
        }
        $this->data = [];
        $this->manialinkFactory = null;
    }
307587
public void destroy() {
    if (dead) return;
    dead = true;

    List<MortarScope> snapshot = new ArrayList<>(children.values());
    for (MortarScope child : snapshot) {
      child.destroy();
    }

    for (Scoped s : tearDowns) {
      s.onExitScope();
    }
    tearDowns.clear();

    Set<String> keys = services.keySet();
    for (String key : keys) {
      services.put(key, "Dead service");
    }
    if (parent != null) {
      parent.children.remove(getName());
    }
  }
1062297
public void destroy()
    {
        if (_ajpIn!=null)
            _ajpIn.destroy();
        _ajpIn=null;
        if (_ajpOut!=null)
            _ajpOut.destroy();
        _ajpOut=null;
        _remoteHost=null;
        _remoteAddr=null;
        _serverName=null;
    }
508609
public function destroy()
	{
		if(!empty($this->children))
		{
			foreach($this->children as $child)
				$child->destroy();
		}
		unset($this->_finder, $this->_parent, $this->model, $this->relation, $this->master, $this->slave, $this->records, $this->children, $this->stats);
	}
551292
public void destroy() {
        try {
            if (indexReader != null) {
                indexReader.close();
            }
            
            writer.close();
            indexTracker.save();
        } catch (IOException e) {
            throw MiscUtil.toUnchecked(e);
        }
    }
293112
public void destroy() {
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Destroy trailers: " + this);
        }
        super.destroy();
        if (null != this.myFactory) {
            this.myFactory.releaseTrailers(this);
            this.myFactory = null;
        }
    }
1224377
@Override
    public void onDestroy() {
        super.onDestroy();

        // very important:
        Log.d(TAG, "Destroying helper.");
        if (mHelper != null) mHelper.dispose();
        mHelper = null;
    }
1014602
@Override
    public final void destroy()
    {
        synchronized (this.connectionMonitor)
        {
            if (this.connection != null)
            {
                this.connection.destroy();
                this.connection = null;
            }
        }
        reset();
    }
324719
public void destroy()
    {
        if (_bufferedOut!=null)
            _bufferedOut.destroy();
        _bufferedOut=null;
        if (_iso8859writer!=null)
            _iso8859writer.destroy();
        _iso8859writer=null;
        if (_utf8writer!=null)
            _utf8writer.destroy();
        _utf8writer=null;
        if (_asciiwriter!=null)
            _asciiwriter.destroy();
        _asciiwriter=null;
    }
1214771
public void destroy() {

		if (bundlesHandler != null) {
			ThreadLocalJawrContext.setInterruptProcessingBundle(true);
		}

		// Stop the config change listener.
		if (null != this.configChangeListenerThread) {
			configChangeListenerThread.stopPolling();
			try {
				configChangeListenerThread.interrupt();
				Thread.sleep(200);
			} catch (InterruptedException e) {
				// Nothing to do
			}
		}
		if (watcher != null) {
			watcher.stopWatching();
			try {
				watcher.interrupt();
				Thread.sleep(200);
			} catch (InterruptedException e) {
				// Nothing to do
			}
		}

		JmxUtils.unregisterJMXBean(servletContext, resourceType,
				jawrConfig.getProperty(JawrConstant.JAWR_JMX_MBEAN_PREFIX));

		ThreadLocalJawrContext.reset();
	}
203931
public void destroy()
    {
        removeAllListeners();
        if (connectionManager != null)
        {
            if(connectionManager.isInLocalTransaction())
            {
                connectionManager.localRollback();
            }
            connectionManager.releaseConnection();
        }
        this.setClosed(true);

        this.descriptorRepository = null;
        this.pbKey = null;
        this.pbf = null;
        this.connectionManager = null;
        this.dbAccess = null;
        this.objectCache = null;
        this.sequenceManager = null;
        this.sqlGenerator = null;
        this.statementManager = null;
    }
1361288
public void destroy() {

        try {
            if (m_projectDriver != null) {
                try {
                    m_projectDriver.destroy();
                } catch (Throwable t) {
                    LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_PROJECT_DRIVER_0), t);
                }
                m_projectDriver = null;
            }
            if (m_userDriver != null) {
                try {
                    m_userDriver.destroy();
                } catch (Throwable t) {
                    LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_USER_DRIVER_0), t);
                }
                m_userDriver = null;
            }
            if (m_vfsDriver != null) {
                try {
                    m_vfsDriver.destroy();
                } catch (Throwable t) {
                    LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_VFS_DRIVER_0), t);
                }
                m_vfsDriver = null;
            }
            if (m_historyDriver != null) {
                try {
                    m_historyDriver.destroy();
                } catch (Throwable t) {
                    LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_HISTORY_DRIVER_0), t);
                }
                m_historyDriver = null;
            }

            if (m_pools != null) {
                for (CmsDbPoolV11 pool : m_pools.values()) {
                    try {
                        pool.close();
                        if (CmsLog.INIT.isDebugEnabled()) {
                            CmsLog.INIT.debug(Messages.get().getBundle().key(Messages.INIT_CLOSE_CONN_POOL_1, pool));
                        }

                    } catch (Throwable t) {
                        LOG.error(Messages.get().getBundle().key(Messages.LOG_CLOSE_CONN_POOL_ERROR_1, pool), t);
                    }
                }
                m_pools.clear();
            }

            m_monitor.clearCache();

            m_lockManager = null;
            m_htmlLinkValidator = null;
        } catch (Throwable t) {
            // ignore
        }
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(Messages.INIT_DRIVER_MANAGER_DESTROY_1, getClass().getName()));
        }
    }
1129613
public void destroy() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "destroy");
        }

        // Go through the hashtable and destroy all long-lived, single instance,
        // resources related to a given TCP Channel type (NIO, AIO, etc...)
        for (ChannelTermination ct : this.terminationList.values()) {
            ct.terminate();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "destroy");
        }
    }