Clean up

Added clean up on exit and exit on exceptions