fixed exit handler