How to trigger an action at the end of the Shell/Bash script

Using Bash/Shell trap, a built-in command to define any action to be executed before exiting the Bash or Shell script. You can define multiple actions and per signal.

List of signals that can be used on Bash / Shell trap
List of trap signals