Looking to do some unique things with drupal_register_shutdown_function. #2222635: Waiting for table metadata lock on cache_field table& #1599622: Run poormanscron via a non-blocking HTTP request are the motivation; run tasks that take a long time in a background request and let contrib (https://drupal.org/project/background_process, https://drupal.org/project/httprl/) handle it.
I'm thinking of doing something like this in hook_exit to capture the shutdown calls.
$callbacks = &drupal_register_shutdown_function();
// Modify $callbacks here.
The other option would be to modify _drupal_shutdown_function so an alternative to call_user_func_array can be used.
try {
$function = \Drupal::config('system.site')->get('drupal_shutdown_function');
while (list($key, $callback) = each($callbacks)) {
$function($callback['callback'], $callback['arguments']);
}
}