Fixed exit trap to be more compatible with sh