[script] use trap to do the cleaning up

The cleaning is done even if the script is stopped with ctrl-c unless
debug level is high enough.

Signed-off-by: Juha Kallioinen <juha.kallioinen@jolla.com>