private function endRequest(int $requestId, int $appStatus = 0, int $protocolStatus = DaemonInterface::FCGI_REQUEST_COMPLETE): void
    {
        $content = pack('NCx3', $appStatus, $protocolStatus);
        $this->writeRecord($requestId, DaemonInterface::FCGI_END_REQUEST, $content);

        $keepAlive = $this->requests[$requestId]['keepAlive'];

        fclose($this->requests[$requestId]['stdin']);

        unset($this->requests[$requestId]);

        if (!$keepAlive) {
            $this->close();
        }
    }