From https://www.php.net/manual/en/function.register-shutdown-function.php
If you call exit() within one registered shutdown function, processing will stop completely and no other registered shutdown functions will be called.
Add a new handler to the very top of the code with the code:
exit();