Internal shutdown used by 'shutdown' method  above
554298
def _shutdown(self, cancel, cancel_msg, exc_type=CancelledError):
        '''  '''
        if cancel:
            # Cancel all in-flight transfers if requested, before waiting
            # for them to complete.
            self._coordinator_controller.cancel(cancel_msg, exc_type)
        try:
            # Wait until there are no more in-progress transfers. This is
            # wrapped in a try statement because this can be interrupted
            # with a KeyboardInterrupt that needs to be caught.
            self._coordinator_controller.wait()
        except KeyboardInterrupt:
            # If not errors were raised in the try block, the cancel should
            # have no coordinators it needs to run cancel on. If there was
            # an error raised in the try statement we want to cancel all of
            # the inflight transfers before shutting down to speed that
            # process up.
            self._coordinator_controller.cancel('KeyboardInterrupt()')
            raise
        finally:
            self._coordinator_controller.cleanup()
955637
def _shutdown_unlocked(self, context, lru=None, new_context=None):
        
        LOG.info('%r._shutdown_unlocked(): shutting down %r', self, context)
        context.shutdown()
        via = self._via_by_context.get(context)
        if via:
            lru = self._lru_by_via.get(via)
            if lru:
                if context in lru:
                    lru.remove(context)
                if new_context:
                    lru.append(new_context)
        self._forget_context_unlocked(context)
1002717
def shutdown(self):
        

        if not self._exited:
            self._exited = True
            _shutdown_pipe(self._pipe)
            self._task.stop()
            raise SystemExit
219802
private void shutdown(){
    parent.workerThreads.get(plan).remove(this);
    if (zk != null) {
      try {
        logger.debug("closing " + zk.getSessionId());
        zk.close();
        zk = null;
      } catch (InterruptedException e1) {
        logger.debug(e1);
      }
      logger.debug("shutdown complete");
    }
  }
1041927
def shutdown(self):
        
        try:
            self._ucan.shutdown()
        except Exception as ex:
            log.error(ex)
874588
public void shutdown() {
        // as resources are returned we need to shut them down
        T t;
        synchronized (lock) {
            isRunning = false;
            t = idleResources.poll();
        }
        while (t != null) {
            returnResource(t, true);
            synchronized (lock) {
                t = idleResources.poll();
            }
        }
    }
1113643
public static function shutdown()
    {
        if (defined('__TIMER_OUT_FILE__')) {
            $strTimerOutput = Timer::varDump(false);
            if ($strTimerOutput) {
                file_put_contents(__TIMER_OUT_FILE__, $strTimerOutput . "\n", FILE_APPEND);
            }
        }

        $error = error_get_last();
        if ($error &&
            is_array($error) &&
            (!defined('\CodeGen::DebugMode') || \CodeGen::DebugMode)
        ) { // if we are codegenning, only error if we are in debug mode. Prevents chmod error.

            QcubedHandleError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line'],
                ''
            );
        }
        //flush();	// required for hhvm
        //error_log("Flushed");
    }
945601
public void shutdown() {
        shutdownCalled = true;
        if (isRunning()) {
            watchdog.waitForProcessStarted();
            watchdog.destroyProcess();
            watchdog.waitForTerminationAfterDestroy(2, SECONDS);
            if (isRunning()) {
                watchdog.destroyProcessForcefully();
                watchdog.waitForTerminationAfterDestroy(1, SECONDS);
                if (isRunning()) {
                    LOGGER.severe(String.format("Unable to kill process with PID %s", watchdog.getProcessId()));
                }
            }
        }

        // if shutdown() was called by something other than the shutdown hook, we don't need the shutdown hook anymore
        try {
            if (shutDownHook != null) {
                Runtime.getRuntime().removeShutdownHook(shutDownHook);
            }
        } catch (IllegalStateException e) {
            // ignore.. happens when the shutdown hook is in use, that's okay
        }

    }
1058970
final void shutdown() {
        _enabled = false;
        _ignoredSegs.clear();
        
        if(_executor != null && !_executor.isShutdown()) {
            try {
                _executor.shutdown();
                _log.info("shutdown");
            } catch (Exception e) {
                _log.warn("shutdown abort", e);
            }
            
            try {
                _executor.awaitTermination(_shutdownTimeout, TimeUnit.SECONDS);
            } catch (Exception e) {
                _log.warn("shutdown abort", e);
            }
            
            if(_segTarget != null) {
                try {
                    _updateManager.endUpdate(_segTarget);
                } catch (Exception e) {
                    _log.warn("shutdown abort", e);
                }
            }
        }
        
        _executor = null;
        _state = State.DONE;
    }
658649
@Override
  public void shutdown(ShutdownModeAmp mode)
  {
    if (mode == ShutdownModeAmp.IMMEDIATE) {
      _stateRef.set(State.CLOSED);
    }
  }
1271438
def _shutdown_timer(self) -> None:
        
        remaining = self._max_run_time - self.uptime
        if not self.shutdown_pending.wait(remaining):
            logger.warning('Run time reached zero')
            self.shutdown()
693981
def shutdown():
    '''
    '''
    global _sdk_ref_count #pylint:disable=global-statement
    global _sdk_instance #pylint:disable=global-statement
    global _should_shutdown #pylint:disable=global-statement

    with _sdk_ref_lk:
        logger.debug("shutdown: ref count = %d, should_shutdown = %s", \
                     _sdk_ref_count, _should_shutdown)
        nsdk = nativeagent.try_get_sdk()
        if not nsdk:
            logger.warning('shutdown: SDK not initialized or already shut down')
            _sdk_ref_count = 0
            return None
        if _sdk_ref_count > 1:
            logger.debug('shutdown: reference count is now %d', _sdk_ref_count)
            _sdk_ref_count -= 1
            return None
        logger.info('shutdown: Shutting down SDK.')
        try:
            if _should_shutdown:
                _rc = nsdk.shutdown()
                if _rc == ErrorCode.NOT_INITIALIZED:
                    logger.warning('shutdown: native SDK was not initialized')
                else:
                    nativeagent.checkresult(nsdk, _rc, 'shutdown')
                _should_shutdown = False
        except SDKError as e:
            logger.warning('shutdown failed', exc_info=sys.exc_info())
            return e
        _sdk_ref_count = 0
        _sdk_instance = None
        nativeagent._force_initialize(None) #pylint:disable=protected-access
        logger.debug('shutdown: completed')
        return None
388697
public function shutdownFunction()
    {
        $this->reservedMemory = null;
        
        $err = $this->errorGetLast();
        $unhandled = E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR;
        
        if (empty($err) || !($err['type'] & $unhandled)) {
            return;
        }
        
        $error = new \ErrorException($err['message'], 0, $err['type'], $err['file'], $err['line']);
        
        if ($err['type'] & $this->getLoggedErrorTypes()) {
            $this->log($error);
        }
        
        $this->callOnFatalError($error);
    }
1334094
public void shutdown() {
        debugConnection = null;
        shuttingDown = true;
        try {
            if (serverSocket != null) {
                serverSocket.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
1076207
private void shutdownImpl(ShutdownModeAmp mode, 
                            ExitCode exitCode,
                            Result<String> result)
  {
    // start the fail-safe thread in case the shutdown fails
    FailSafeHaltThread haltThread = _failSafeHaltThread;
    
    if (haltThread != null) {
      haltThread.startShutdown();
    }

    if (exitCode == null) {
      exitCode = ExitCode.FAIL_SAFE_HALT;
    }
    
    _exitCode.compareAndSet(null, exitCode);

    try {
      SystemManager systemManager = _systemManagerRef.get();
        
      if (systemManager != null) {
        systemManager.shutdown(mode);
      }
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
    } finally {
      _systemManagerRef = null;
      _lifecycle.toDestroy();

      System.err.println("\nShutdown reason: " + exitCode + "\n");

      log.warning("Shutdown reason: " + exitCode);
      
      if (result != null) {
        result.ok("Shutdown reason: " + exitCode);
      }

      if (! _isEmbedded) {
        System.exit(exitCode.ordinal());
      }
    }
  }
173070
public synchronized void shutDown() {

        int count = 0;
        Iterator<String> it = getModuleNames().iterator();
        while (it.hasNext()) {
            String moduleName = it.next();
            // get the module
            CmsModule module = m_modules.get(moduleName);
            if (module == null) {
                continue;
            }
            // get the module action instance
            I_CmsModuleAction moduleAction = module.getActionInstance();
            if (moduleAction == null) {
                continue;
            }

            count++;
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(
                    Messages.get().getBundle().key(
                        Messages.INIT_SHUTDOWN_MOD_CLASS_1,
                        moduleAction.getClass().getName()));
            }
            try {
                // shut down the module
                moduleAction.shutDown(module);
            } catch (Throwable t) {
                LOG.error(
                    Messages.get().getBundle().key(
                        Messages.LOG_INSTANCE_SHUTDOWN_ERR_1,
                        moduleAction.getClass().getName()),
                    t);
            }
        }

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_NUM_MOD_CLASSES_1, new Integer(count)));
        }

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SHUTDOWN_1, this.getClass().getName()));
        }
    }
1037291
@Override
  public void shutdown() {
    LOG.info("Shutting down ...");
    shouldShutdown = true;
    if (tserver != null) {
      tserver.stop();
    }
    started = false;
  }