Request the slave gracefully shut itself down.
342982
def on_shutdown(self, broker):
        """"""
        LOG.debug('%r closing CALL_FUNCTION channel', self)
        self._send(
            mitogen.core.Message(
                src_id=mitogen.context_id,
                dst_id=self.remote_id,
                handle=mitogen.core.SHUTDOWN,
            )
        )
1002717
def shutdown(self):
        

        if not self._exited:
            self._exited = True
            _shutdown_pipe(self._pipe)
            self._task.stop()
            raise SystemExit
321629
public void shutdown()
  {
    log.info("Shutting down...");
    isShutdownRequested = true;

    try
    {
      mainThread.join();
    }
    catch (InterruptedException e)
    {
      log.error(
        "Interrupted which waiting on main daemon thread to complete.");
    }
  }
471999
def shutdown(self):
        """"""

        if self.verbose:
            print(self.socket.getsockname(), 'xx', self.peername)

        try:
            self.socket.shutdown(socket.SHUT_RDWR)
        except IOError as err:
            assert err.errno is _ENOTCONN, "unexpected IOError: %s" % err
            # remote peer has already closed the connection,
            # just ignore the exceeption
            pass
1253499
def on_server_shutdown(self):
        """"""
        if not self._container:
            return
        self._container.stop()
        self._container.remove(v=True, force=True)
57201
async def shutdown(self, force = False, connmark = -1):
        '''
        
        '''
        if connmark is None:
            connmark = self.connmark
        self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.SHUTDOWN, force, connmark))
157955
@CLIMethod(name="safe-shutdown")
    @RequirePOST
    public HttpResponse doSafeExit(StaplerRequest req) throws IOException {
        checkPermission(ADMINISTER);
        isQuietingDown = true;
        final String exitUser = getAuthentication().getName();
        final String exitAddr = req!=null ? req.getRemoteAddr() : "unknown";
        new Thread("safe-exit thread") {
            @Override
            public void run() {
                try {
                    ACL.impersonate(ACL.SYSTEM);
                    LOGGER.info(String.format("Shutting down VM as requested by %s from %s",
                                                exitUser, exitAddr));
                    // Wait 'til we have no active executors.
                    doQuietDown(true, 0);
                    // Make sure isQuietingDown is still true.
                    if (isQuietingDown) {
                        cleanUp();
                        System.exit(0);
                    }
                } catch (Exception e) {
                    LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e);
                }
            }
        }.start();

        return HttpResponses.plainText("Shutting down as soon as all jobs are complete");
    }
150808
async def shutdown(self):
        ""
        if self.stream:
            if not self.stream.dataeof and not self.stream.dataerror:
                self.stream.close(self.scheduler)
                await self.connection.shutdown()
            else:
                self.stream.close(self.scheduler)
            self.stream = None
352588
def shut_down():
    """"""
    curses.nocbreak()
    curses.echo()
    curses.endwin()
    gpsd_socket.close()
    print('Keyboard interrupt received\nTerminated by user\nGood Bye.\n')
    sys.exit(1)
997328
def shutdown(self):
        ''
        log.info("shutting down")
        self._peer.go_down(reconnect=False, expected=True)
680857
public void shutdown() {
        logger.info("Closing Retrieval Manager");
        workerPool.shutdown();

        try {
            workerPool.awaitTermination(30, TimeUnit.MINUTES);
        } catch (InterruptedException e) {
            // Exit wait on interruption
        }

        complete = true;
    }
1060064
@Override
  public void onShutdownRequest() {
    this.reefEventHandlers.onRuntimeStatus(RuntimeStatusEventImpl.newBuilder()
        .setName(RUNTIME_NAME).setState(State.DONE).build());
    this.driverStatusManager.onError(new Exception("Shutdown requested by YARN."));
  }
581291
def shutdown(self, exitcode=0, exitmsg=None):
        '''
        
        '''
        if hasattr(self, 'minion') and 'proxymodule' in self.minion.opts:
            proxy_fn = self.minion.opts['proxymodule'].loaded_base_name + '.shutdown'
            self.minion.opts['proxymodule'][proxy_fn](self.minion.opts)
        self.action_log_info('Shutting down')
        super(ProxyMinion, self).shutdown(
            exitcode, ('The Salt {0} is shutdown. {1}'.format(
                self.__class__.__name__, (exitmsg or '')).strip()))
1335549
def request_stop(self, message='', exit_code=0):
        
        # Log an error message if exit code is not 0
        # Force output to stderr
        if exit_code:
            if message:
                logger.error(message)
                try:
                    sys.stderr.write(message)
                except Exception:  # pylint: disable=broad-except
                    pass
            logger.error("Sorry, I bail out, exit code: %d", exit_code)
            try:
                sys.stderr.write("Sorry, I bail out, exit code: %d" % exit_code)
            except Exception:  # pylint: disable=broad-except
                pass
        else:
            if message:
                logger.info(message)

        self.unlink()
        self.do_stop()

        logger.info("Stopped %s.", self.name)
        sys.exit(exit_code)
232118
final public function shutdown() : void
    {
        $this->__call('shutdown');
        Master::wait($this->backend->process()->pid ?? -2);
    }
1082390
def serve_forever():
    '''
    
    '''
    if not util.main_host.alive:
        raise Exception("This host is already shutted down.")
    util.main_host.serving = True
    signal.signal(SIGINT, signal_handler)
    print 'Press Ctrl+C to kill the execution'
    while util.main_host is not None and util.main_host.serving:
        try:
            sleep(1)
        except Exception:
            pass
    print 'BYE!'
791622
def _shutdown(self):
        """"""
        if self._channel:
            _log.info("Halting %r consumer sessions", self._channel.consumer_tags)
        self._running = False
        if self._connection and self._connection.is_open:
            self._connection.close()
        # Reset the signal handler
        for signum in (signal.SIGTERM, signal.SIGINT):
            signal.signal(signum, signal.SIG_DFL)