Gracefully shutdown the daemon.

@throws \Exception
421617
private function shutdown(): void
    {
        $this->connectionPool->shutdown();

        foreach ($this->connectionHandlers as $connectionHandler) {
            $connectionHandler->shutdown();
        }

        while ($this->connectionPool->count() > 0) {
            $this->processConnectionPool();
        }

        $this->connectionPool->close();
    }
696662
private function quit()
    {
        $this->output->writeln('Stopping the process manager.');

        // this method is also called during startup when something crashed, so
        // make sure we don't operate on nulls.
        if ($this->controller) {
            @$this->controller->close();
        }
        if ($this->web) {
            @$this->web->close();
        }

        if ($this->loop) {
            $this->loop->stop();
        }

        unlink($this->pidfile);
        exit;
    }
854164
public function handleClose()
    {
        $this->pause();

        if (is_resource($this->socket))
        {
            if ($this->getStreamType() === Socket::TYPE_UNIX)
            {
                $path = substr($this->parseEndpoint(), 7);
                unlink($path);
            }
            fclose($this->socket);
        }
    }
745416
public function disconnect()
    {
        try {
            if ($this->stream) {
                $this->stream->close();
                $this->stream = null;
            }
        } catch (\Throwable $e) {
            \danog\MadelineProto\Logger::log('Got exception while closing stream: '.$e->getMessage());
        } catch (\Exception $e) {
            \danog\MadelineProto\Logger::log('Got exception while closing stream: '.$e->getMessage());
        }
    }
827812
def exit(self):
        
        self.logger.warning("Stopping daemon.")
        os.remove(self.pid)
        sys.exit(0)
1030117
public void shutdown() {
        executorService.shutdown();
        scheduler.shutdown();
        daemonScheduler.shutdown();
        executorServiceSingleThreads.values().forEach(ExecutorService::shutdown);
    }
90927
public function stop()
    {
        if ($this->pid) {
            exec('kill ' . $this->pid, $output, $ret);
            if ($ret !== 0) {
                throw new Exception('Error stopping build-in server.');
            }
            $this->pid = null;
        }
    }
903935
def shutdown(self):
        
        self.run_clean_thread = False
        self.cleanup(True)
        if self.cleaner_thread.isAlive():
            self.cleaner_thread.join()
1113944
public static function stop() {
		if (!self::is_running()) {
			throw new \Exception('Transaction daemon is not running');
		}

		$pid = file_get_contents(Config::$pid_file);
		$return = posix_kill($pid, 15);
		if ($return === false) {
			throw new \Exception('Unable to kill daemon');
		}
		Transaction::unlock_all();
		return true;
	}
1007450
public function shutdownProcesses()
    {
        foreach ($this->processes as $pid => $process) {
            unset($this->processes[$pid]);
    
            posix_kill($pid, SIGUSR1);
        }
    
        exit;
    }
1014417
public function shutdown()
    {
        if (!empty($this->ch)) {
            curl_close($this->ch);
            $this->ch = null;
        }
    }
354901
void shutdown() throws IOException {
        synchronized (this) {
            for (BdbEnvironmentInfo envInfo : this.envInfos) {
                try {
                    envInfo.getClassCatalog().close();
                } catch (DatabaseException ignore) {
                    LOGGER.log(Level.SEVERE, "Failure closing class catalog", ignore);
                }
                envInfo.closeAndRemoveAllDatabaseHandles();
                
                try (Environment env = envInfo.getEnvironment()) {
                    if (this.deleteOnExit) {
                        FileUtil.deleteDirectory(env.getHome());
                    }
                }
            }
            this.envInfos.clear();
        }
    }
1110735
public function shutdown()
    {

        // check if there was a fatal error caused shutdown
        if ($lastError = error_get_last()) {
            // initialize error type and message
            $type = 0;
            $message = '';
            // extract the last error values
            extract($lastError);
            // query whether we've a fatal/user error
            if ($type === E_ERROR || $type === E_USER_ERROR) {
                LoggerUtils::log(LogLevel::CRITICAL, $message);
            }
        }
    }
1095740
public static function shutdown()
    {
        global $PPHP;
        $req = grab('request');

        if (!$req['binary']) {
            $body = ob_get_contents();
            ob_end_clean();
            try {
                array_merge_assoc(
                    self::$_stash,
                    array(
                        'body' => self::$_safeBody,
                        'stdout' => $body,
                        'config' => $PPHP['config'],
                        'session' => $_SESSION,
                        'req' => grab('request')
                    )
                );
                self::$_template->displayBlock('body', self::$_stash);
            } catch (\Exception $e) {
                echo $e->getMessage();
            };
        };
    }
35091
public static function __shutdownCleanup()
    {
        $now = time();

        if (is_array(self::$lockFiles)) {
            foreach (self::$lockFiles as $lockFile => $meta) {
                if (($now - $meta['time'] > $meta['ttl']) && file_exists($lockFile)) {
                    unlink($lockFile);
                }
            }
        }
    }
679245
protected void teardown() throws Exception {
    logger.fine("shutting down channels");
    for (ManagedChannel channel : channels) {
      channel.shutdown();
    }
    logger.fine("shutting down server");
    server.shutdown();
    if (!server.awaitTermination(5, TimeUnit.SECONDS)) {
      logger.warning("Failed to shutdown server");
    }
    logger.fine("server shut down");
    for (ManagedChannel channel : channels) {
      if (!channel.awaitTermination(1, TimeUnit.SECONDS)) {
        logger.warning("Failed to shutdown client");
      }
    }
    logger.fine("channels shut down");
  }
1055445
public function quit()
    {
        if ($this->connected && $this->socket) {
            $this->executeCommand('QUIT');
            $close = @fclose($this->socket);
            if (!$close) {
                throw new Exception\IOError('Error while closing the connection to the Tor server');
            }
        }

        $this->connected = false;
    }