protected function shutdownHandlerCallback(
        ServerRequestInterface $request,
        ResponseInterface $response
    ) : callable {
        /**
         * Shutdown Handler
         */
        return function () use($request, $response) {
            if ($this->haltShutDown === true) {
                return;
            }
            $lastError = error_get_last();
            if (empty($lastError['type'])
                // check if error type is valid error
                || ! in_array($lastError['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR])
            ) {
                return;
            }
            // serve the end of response
            $this->serveResponse(
                $this->getErrorHandler()(
                $request,
                $response,
                new \Error($lastError['message'], $lastError['type'])
            ));
            // exit with 255 code
            exit(255);
        };
    }