---

Using Trap to Exit Bash Scripts Cleanly

In this tutorial we explain how to use the trap bash builtin to exit bash scripts cleanly. We explore example of how to clean up temp file, ensure services stay running and close ports.