For all intents and purposes, if you trap exit, it will be executed when the shell process terminates. Exit the shell, returning a status of n to the shell's parent. If n is omitted, the exit status is that of the last command executed. Any trap on EXIT is executed before the shell terminates.