A trap on the special signal EXIT is executed before the shell terminates. EXIT actually covers SIGINT and SIGTERM as well, and we don't need any extra traps for them. See bash(1) and "help trap" in bash.