Función de apagado de PHP
register_shutdown_function(function () {
# code
});
Healthy Hare
register_shutdown_function(function () {
# code
});