This is a compatibility function which provides the logic for
    nspawn.poweroff and nspawn.terminate.
189469
def stop(name, kill=False):
    '''
    
    '''
    if _sd_version() >= 219:
        if kill:
            action = 'terminate'
        else:
            action = 'poweroff'
        ret = _machinectl('{0} {1}'.format(action, name))
    else:
        cmd = 'systemctl stop systemd-nspawn@{0}'.format(name)
        ret = __salt__['cmd.run_all'](cmd, python_shell=False)

    if ret['retcode'] != 0:
        __context__['retcode'] = salt.defaults.exitcodes.EX_UNAVAILABLE
        return False
    return True
463288
def on_terminate(func):
    """"""
    def exit_function(*args):
        func()
        exit(0)
    signal.signal(signal.SIGTERM, exit_function)
1152401
def finish(self):
        
        super(InterruptibleMixin, self).finish()
        signal(SIGINT, self.original_handler)
1079823
def signal_terminate(on_terminate):
    """"""
    for i in [signal.SIGINT, signal.SIGQUIT, signal.SIGUSR1, signal.SIGUSR2, signal.SIGTERM]:
        signal.signal(i, on_terminate)
539482
def close(self, terminate=True, kill=False):
        '''
        
        '''
        if not self.closed:
            if self.child_fd is not None:
                os.close(self.child_fd)
                self.child_fd = None
            if self.child_fde is not None:
                os.close(self.child_fde)
                self.child_fde = None
            time.sleep(0.1)
            if terminate:
                if not self.terminate(kill):
                    raise TerminalException('Failed to terminate child process.')
            self.closed = True
243339
def stop(self):
        
        self.child.terminate()
        self._cleanup()
        return self.child.exitcode
283758
def terminate(self):
        
        for w in self.q.values():
            try:
                w.terminate()
            except:
                pass

        self.q = {}
875487
async def end_delegate(self, delegate_matcher, routine = None, forceclose = False):
        
        try:
            ev = await delegate_matcher
            if hasattr(ev, 'exception'):
                raise ev.exception
            else:
                return ev.result
        finally:
            if forceclose and routine:
                routine.close()
591288
def exit_with_error(self, error, **kwargs):
        
        self.error(error, **kwargs)
        raise SystemExit(error)
416842
public static ns stop(nitro_service client, ns resource) throws Exception
	{
		return ((ns[]) resource.perform_operation(client, "stop"))[0];
	}
801243
def _finalCleanup(self):
        
        for conn in self._connections.values():
            conn.releaseConnectionResources()
        assert not self._connections
1261369
def _possibly_exit_with_help(parser, known_args):
        
        if known_args.core_help or known_args.core_help_all:
            parser.print_help()
            sys.exit()
1306163
def power_off(self):
        """"""
        try:
            self.send_command("POWER_OFF")
            self._power = POWER_OFF
            self._state = STATE_OFF
            return True
        except requests.exceptions.RequestException:
            _LOGGER.error("Connection error: power off command not sent.")
            return False
646015
protected final void terminate() {
		if (rebind(connection)) {
			if (log.isTraceEnabled()) {
				log.trace(format(channel(), "Disposing ChannelOperation from a channel"),
						new Exception("ChannelOperation terminal stack"));
			}

			Operators.terminate(OUTBOUND_CLOSE, this);
			// Do not call directly inbound.onInboundComplete()
			// HttpClientOperations need to notify with error
			// when there is no response state
			onInboundComplete();
			if (channel().isActive() && isPersistent()) {
				channel().writeAndFlush(TERMINATED_OPS, this);
			}
			else {
				// Returned value is deliberately ignored
				setSuccess(null);
			}
		}
	}
1037563
public function terminate($output = null)
    {
        if ($output !== null) {
            echo $output;
        }
        $this->run_called = true; // prevent shutdown function from triggering.
        $this->callExit();
    }
338259
public void quit()
	{
		if (pc != null) {
			final KNXNetworkLink lnk = pc.detach();
			if (lnk != null)
				lnk.close();
			Runtime.getRuntime().removeShutdownHook(sh);
		}
	}
1090066
def exit(self):
        ''''''
        self.output.write("Happy hacking!")
        self.output.nextLine()
        self.output.loseConnection()