Quit correctly when an exception reaches main.py