With a shutdown function, when the remote user hits his STOP button, the next time your script tries to output something PHP will detect that the connection has been aborted and the shutdown function is called.
Cette fonction sera aussi appelée à la fin du script, si celui-ci se termine normalement.