Shuts down the pool and all workers in it.

@return \Amp\Promise<int[]> Array of exit status from all workers.

@throws \Amp\Parallel\Context\StatusError If the pool has not been started.
175478
public function shutdown(): Promise
    {
        if ($this->exitStatus) {
            return $this->exitStatus;
        }

        $this->running = false;

        $shutdowns = [];
        foreach ($this->workers as $worker) {
            if ($worker->isRunning()) {
                $shutdowns[] = $worker->shutdown();
            }
        }

        return $this->exitStatus = Promise\all($shutdowns);
    }
847156
public function stop()
    {
        // Try to emit onWorkerStop callback.
        if ($this->onWorkerStop) {
            try {
                call_user_func($this->onWorkerStop, $this);
            } catch (\Exception $e) {
                static::log($e);
                exit(250);
            } catch (\Error $e) {
                static::log($e);
                exit(250);
            }
        }
        // Remove listener for server socket.
        $this->unlisten();
        // Close all connections for the worker.
        if (!static::$_gracefulStop) {
            foreach ($this->connections as $connection) {
                $connection->close();
            }
        }
        // Clear callback.
        $this->onMessage = $this->onClose = $this->onError = $this->onBufferDrain = $this->onBufferFull = null;
    }
344834
public function close()
    {
        $deferred = new Deferred();

        if (! $this->ready) {
            $deferred->reject(new \Exception('Voice Client is not connected.'));

            return $deferred->promise();
        }

        $this->stop();
        $this->setSpeaking(false);
        $this->ready = false;

        $this->mainSend([
            'op' => Op::OP_VOICE_STATE_UPDATE,
            'd'  => [
                'guild_id'   => $this->channel->guild_id,
                'channel_id' => null,
                'self_mute'  => true,
                'self_deaf'  => true,
            ],
        ]);

        $this->client->close();
        $this->voiceWebsocket->close();

        $this->heartbeat_interval = null;
        $this->loop->cancelTimer($this->heartbeat);
        $this->loop->cancelTimer($this->udpHeartbeat);
        $this->heartbeat      = null;
        $this->udpHeartbeat   = null;
        $this->seq            = 0;
        $this->timestamp      = 0;
        $this->sentLoginFrame = false;
        $this->startTime      = null;
        $this->streamTime     = 0;
        $this->speakingStatus = new Collection([], 'ssrc');

        $this->emit('close');

        $deferred->resolve();

        return $deferred->promise();
    }
21750
def close(self):
        
        with self._lock:
            if self._closing:
                return
            self._closing = True
            if not self._workers:
                self._closed.set()
                return
            self._queue.put_nowait(self._PoolClosing)
        self._closed.wait()
445377
public void shutdown() {
	    if (shutdown) 
	    {
	        return;
	    }
	    shutdown = true;
	    synchronized (workers) 
	    {
	        for (int i = workers.size(); i > 0; i--) 
	        {
	        	systemExecute(exitTask);
	        }
	        waitConditionStrategy.signalAllWhenBlocking();
	    }
	}
11097
public function stop()
    {
        $deferred = new Deferred();

        $onStop = $this->onStop;
        $onStop()
            ->then(function () use (&$deferred) {
                $this->ariClient->onClose(function () use (&$deferred) {
                    $this->eventLoop->stop();
                    $deferred->resolve();
                });
                $this->wsClient->close();
            });

        return $deferred->promise();
    }
631697
def shutdown(force=false)
      status(:closed)
      args = []
      args.push(:force) if force
      @logger.info("Pool is now shutting down #{force ? 'using force' : ''}")
      @queue.clear if force
      @queue.wait_empty
      while(t = @threads.pop) do
        t.stop(*args)
      end
      unless(force)
        flush
        @threads.each{|x|x.join}
      end
      nil
    end
458710
public function close()
    {
        $this->closed = true;
        foreach ($this->connections as $connection) {
            $connection->close();
        }
        $this->idle = new \SplQueue;

        if ($this->deferred instanceof Deferred) {
            $deferred = $this->deferred;
            $this->deferred = null;
            $deferred->fail(new FailureException("Connection pool closed"));
        }
    }
448229
def on_worker_exit(worker)
      mutex.synchronize do
        @pool.delete(worker)
        if @pool.empty? && !running?
          stop_event.set
          stopped_event.set
        end
      end
    end
945821
public function shutdown()
    {
        // check if there was a fatal error caused shutdown
        if ($lastError = error_get_last()) {
            // initialize type + 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) {
                error_log($message);
            }
        }
    }
511761
public function stop()
    {

        // start application shutdown
        $this->synchronized(function ($self) {
            $self->applicationState = ApplicationStateKeys::get(ApplicationStateKeys::HALT);
        }, $this);

        do {
            // log a message that we'll wait till application has been shutdown
            \info(sprintf('Wait for application %s to be shutdown', $this->getName()));

            // query whether application state key is SHUTDOWN or not
            $waitForShutdown = $this->synchronized(function ($self) {
                return $self->applicationState->notEquals(ApplicationStateKeys::get(ApplicationStateKeys::SHUTDOWN));
            }, $this);

            // wait one second more
            sleep(1);

        } while ($waitForShutdown);
    }
383217
public function shutdownProcess()
    {
        $event = $this->dispatchEvent('Controller.shutdown');
        if ($event->getResult() instanceof Response) {
            return $event->getResult();
        }

        return null;
    }
330055
public function shutdownCallback()
    {
        // Output our chunks.
        // Every output is split into 4 chunk strings (header, messages,
        // data, footer).
        foreach ($this->chunkStrings as $chunkString) {
            // Send it to the browser.
            $this->pool->chunks->sendDechunkedToBrowser($chunkString);
        }
    }
1331794
protected function handleWorkerExit()
    {
        $result = swoole_process::wait();

        if(!empty($this->_noRestartProcesses[$result['pid']])) {
            unset($this->_noRestartProcesses[$result['pid']]);
            return;
        }

        if($result['signal'] > 0) {
            if($this->restartPolicy & self::RESTART_ON_SIGNAL) {
                $this->forkOneWorker();
            }
        } else {
            if($result['code'] > 0) {
                $this->_errors[] = microtime(true);

                if($this->restartPolicy & self::RESTART_ON_ERROR && !$this->_disableRestartOnError) {
                    if($this->tooManyErrors()) {
                        //if exceed the maximum error frequency, stop forking new workers on error
                        $this->_disableRestartOnError = true;
                    } else {
                        $this->forkOneWorker();
                    }
                }
            } else {
                if($this->restartPolicy & self::RESTART_ON_EXIT) {
                    $this->forkOneWorker();
                }
            }
        }
    }
1091567
public function shutdown()
    {
        $error = error_get_last();
        if ($error !== null ) {
            $this->setMessage($error['message']);
            $this->setStatusCode(500, $error['message']);
            $this->outputBody();
            exit();
        }
    }
788810
function close() {
        if (isset($this->res)) {
            $this->stdout->close();
            fclose($this->pipes[0]);
            $status = $this->status();
            $exit = $status['running'] ? proc_close($this->res) : $status['exitcode'];
            unset($this->res, $this->pipes, $this->stdout);
            return $exit;
        }
        return null;
    }
1135185
public function clear()
    {
        return PoolManager::use($this->poolName, function($resource, \Imi\Redis\RedisHandler $redis){
            return $redis->flushDB();
        });
    }