Shutdown the channel with all resources released.

@param force force immediate shutdown.
481681
public synchronized void shutdown(boolean force) {

        if (shutdown) {
            return;
        }

        String ltransactionListenerProcessorHandle = transactionListenerProcessorHandle;
        transactionListenerProcessorHandle = null;
        if (null != ltransactionListenerProcessorHandle) {

            try {
                unregisterBlockListener(ltransactionListenerProcessorHandle);
            } catch (Exception e) {
                logger.error(format("Shutting down channel %s transactionListenerProcessorHandle", name), e);
            }
        }

        String lchaincodeEventUpgradeListenerHandle = chaincodeEventUpgradeListenerHandle;
        chaincodeEventUpgradeListenerHandle = null;
        if (null != lchaincodeEventUpgradeListenerHandle) {

            try {
                unregisterChaincodeEventListener(lchaincodeEventUpgradeListenerHandle);
            } catch (Exception e) {
                logger.error(format("Shutting down channel %s chaincodeEventUpgradeListenr", name), e);
            }
        }

        initialized = false;
        shutdown = true;

        final ServiceDiscovery lserviceDiscovery = serviceDiscovery;
        serviceDiscovery = null;
        if (null != lserviceDiscovery) {
            lserviceDiscovery.shutdown();
        }

        if (chainCodeListeners != null) {
            chainCodeListeners.clear();

        }

        if (blockListeners != null) {
            blockListeners.clear();
        }

        if (client != null) {
            client.removeChannel(this);
        }

        client = null;

        for (Peer peer : new ArrayList<>(getPeers())) {

            try {
                removePeerInternal(peer);
                peer.shutdown(force);
            } catch (Exception e) {
                // Best effort.
            }
        }
        peers.clear(); // make sure.

        peerEndpointMap.clear();
        ordererEndpointMap.clear();

        //Make sure
        for (Set<Peer> peerRoleSet : peerRoleSetMap.values()) {
            peerRoleSet.clear();
        }

        for (Orderer orderer : getOrderers()) {
            orderer.shutdown(force);
        }

        orderers.clear();

        if (null != eventQueueThread) {
            eventQueueThread.interrupt();
            eventQueueThread = null;
        }
        ScheduledFuture<?> lsweeper = sweeper;
        sweeper = null;

        if (null != lsweeper) {
            lsweeper.cancel(true);
        }

        ScheduledExecutorService lse = sweeperExecutorService;
        sweeperExecutorService = null;
        if (null != lse) {
            lse.shutdownNow();
        }
    }
238098
private void closeChannel() {
        if (this.channel != null) {
            if (this.channel.isConnected()) {
                try {
                    this.channel.disconnect();
                } catch (IOException e) {
                    logger.warn(e.getMessage(), e);
                }
            }

            if (this.channel.isOpen()) {
                try {
                    this.channel.close();
                } catch (IOException e) {
                    logger.warn(e.getMessage(), e);
                }
            }
        }
    }
1354080
void closeChannel(final Channel channel) {
        synchronized (channelClosing) {
            if (closingChannel.contains(channel)) {
                LOG.info(channel.toString() + " has already been closed");
                return;
            }

            closingChannel.add(channel);
        }

        LOG.debug(channel.toString() + " begin to close");
        ChannelFuture closeFuture = channel.close();
        closeFuture.addListener(new ChannelFutureListener() {
            public void operationComplete(ChannelFuture future) throws Exception {

                synchronized (channelClosing) {
                    closingChannel.remove(channel);
                }
                LOG.debug(channel.toString() + " closed.");
            }
        });
    }
775732
public void release()
    {
        super.release();

        _forceId = null;
        _forceIdIndex = null;

        _value = null;
        _converter = null;

        _javascriptLocation = null;
        _imageLocation = null;
        _styleLocation = null;
    }
281106
@Override
  public void shutdown(ShutdownModeAmp mode)
  {
    TreeSet<String> serviceNames = new TreeSet<>(_serviceMap.keySet());
    
    // HashSet<ServiceRefAmp> serviceSet = new HashSet<>(_serviceMap.values());
    
    if (mode == ShutdownModeAmp.GRACEFUL) {
      save(serviceNames);
    }
    
    for (String serviceName : serviceNames) {
      try {
        ServiceRefAmp serviceRef = _serviceMap.get(serviceName);
        
        serviceRef.shutdown(mode);
      } catch (Throwable e) {
        log.log(Level.FINE, e.toString(), e);
      }
    }
  }
517711
protected void shutdownInput() throws IOException {
      if (fd != null && fd.valid()) {
          socketShutdown(SHUT_RD);
          if (socketInputStream != null) {
              socketInputStream.setEOF(true);
          }
          shut_rd = true;
      }
    }
219491
@Override
  @TearDown(Level.Trial)
  public void teardown() throws Exception {
    completed.set(true);
    if (!latch.await(5, TimeUnit.SECONDS)) {
      logger.warning("Failed to shutdown all calls.");
    }

    super.teardown();
  }
1033265
function forceClose(channel) {
    if (!channel) return;

    var destroyer = setTimeout(function () {
      channel.destroy();
    }, 200);

    channel.once('close', function () {
      clearTimeout(destroyer);
    });
  }
321746
@Override
  public void close() {
    if (closed) return;
    
    closed = true;
    
    try {
      channel.close();
    } catch (Exception e) {
      logger.log("Failed to close channel for: '" + name + "'", e);
    }
  }
539692
protected static void shutdownClient() {
		if (ddbClient != null) {
			ddbClient.shutdown();
			ddbClient = null;
			ddb.shutdown();
			ddb = null;
		}
	}
571992
public static synchronized void shutDown() {
    if (sInstance != null) {
      sInstance.getBitmapMemoryCache().removeAll(AndroidPredicates.<CacheKey>True());
      sInstance.getEncodedMemoryCache().removeAll(AndroidPredicates.<CacheKey>True());
      sInstance = null;
    }
  }
979346
public void shutdown() {
        lock.lock();
        try {
            isShutdown = true;
            notEmpty.signalAll();
            notFull.signalAll();
        }
        finally {
            lock.unlock();
        }
    }
480503
@Override
    public void destroy() {
        synchronized (channels) {
            isCurrentlyShutingDown = true;
            for (final SynchronizeFXTomcatChannel server : channels.values()) {
                server.shutdown();
            }
            servers.clear();
            channels.clear();
            isCurrentlyShutingDown = false;

        }
    }
234524
@Override
    public void shutdown ()
    {
        _shutdownRequested = true;
        _queue.append(new Unit() {
            @Override public boolean invoke () {
                _running = false;
                return false;
            }
        });
    }
1205332
public static synchronized void shutdown()
    {
        if( c_factories == null ) return; // Nothing to do

        for( Iterator<Entry<String, StopWatchFactory>> i = c_factories.entrySet().iterator(); i.hasNext() ; )
        {
            Map.Entry<String,StopWatchFactory> e = i.next();

            StopWatchFactory swf = e.getValue();
            swf.internalShutdown();

            i.remove();
        }

        c_factories = null;
    }
1162611
public static void shutDownActorSystemForce() {
        if (!actorSystem.isTerminated()) {
            logger.info("shutting down actor system...");
            actorSystem.shutdown();
            actorSystem.awaitTermination(timeOutDuration);
            logger.info("Actor system has been shut down.");
        } else {
            logger.info("Actor system has been terminated already. NO OP.");
        }

    }
116000
public Future<Void> forceClose() {
    this.close();
    if (forceClosing.compareAndSet(false, true) && channel.isOpen()) {
      writeCoalescer
          .writeAndFlush(channel, FORCEFUL_CLOSE_MESSAGE)
          .addListener(UncaughtExceptions::log);
    }
    return channel.closeFuture();
  }