Use a function for trap exit