Shutdown functions are functions that are executed after the current scope has been "shutdown". Say, you want to run a function after another function has completed execution, then this is the way to go. It is also a way to make PHP web requests somewhat asynchronous. In a Drupal context, say you are sending a request, that triggers a function. But you do not want to wait for the response or you want the function to start executing after the request has returned a response. All you have to do is register a shutdown function within the function you are triggering using the request. Say you have a Drupal controller with the function page(). Inside this function call drupal_register_shutdown_function("yourfunction"). The function "yourfunction" will start execution after page() has completed execution.
PHP example:
<?php
function shutdown()
{
// This is our shutdown function, this
// function will be executed when the php
// file completes execution.
echo 'Script executed with success', PHP_EOL;
}
register_shutdown_function('shutdown');
?>