protected function closeOutputBuffers(int $targetLevel = 0, bool $flush = false): void
    {
        $status = ob_get_status(true);
        $level = \count($status);

        while ($level-- > $targetLevel) {
            $flush ? ob_end_flush() : ob_end_clean();
        }
    }