yii\base\Application::end PHP Method

end() public method

This method replaces the exit() function by ensuring the application life cycle is completed before terminating the application.
public end ( integer $status, Response $response = null )
$status integer the exit status (value 0 means normal exit while other values mean abnormal exit).
$response Response the response to be sent. If not set, the default application [[response]] component will be used.
    public function end($status = 0, $response = null)
    {
        if ($this->state === self::STATE_BEFORE_REQUEST || $this->state === self::STATE_HANDLING_REQUEST) {
            $this->state = self::STATE_AFTER_REQUEST;
            $this->trigger(self::EVENT_AFTER_REQUEST);
        }
        if ($this->state !== self::STATE_SENDING_RESPONSE && $this->state !== self::STATE_END) {
            $this->state = self::STATE_END;
            $response = $response ?: $this->getResponse();
            $response->send();
        }
        if (YII_ENV_TEST) {
            throw new ExitException($status);
        } else {
            exit($status);
        }
    }