Detecting whether PHP is shutting down
<p>How can I detect whether PHP is shutting down? By "shutting down", I mean that a function registered with <a href="http://php.net/manual/en/function.register-shutdown-function.php" rel="nofollow noreferrer"><code>register_shutdown_function</code></a> is currently executing. For example, consider the following code:</p>

<pre><code>&lt;?php

function do_something() {
    // How can I detect whether PHP is shutting down.
}

register_shutdown_function('do_something');
do_something();
</code></pre>

<p>In the above code snippet, I want to be able to detect shutdown from within the <code>do_something</code> function.</p>