Make this a function and call it. Then also put a `trap cleanup exit` at the top of the script. [More on traps](http://redsymbol.net/articles/bash-exit-traps/).