exit() completes the execution of the script - so after creating it there is not as much as you could do.
However, quoting the manual:
The shutdown functions and the destructor object will always be executed, even if exit() called.
Thus, you cannot โcall another procedureโ when exit() is called, but you can register a function that will be called every time the PHP script ends; including the time when it exits due to the call to exit() .
source share