For the \"q\" (quit) option in my program menu, I have the following code:
elif choice == \"q\":
print()
That worked all right until I
Please note that the solutions based on sys.exit() or any Exception may not work in a multi-threaded environment.
Since exit() ultimately “only” raises an exception, it will only exit the process when called from the main thread, and the exception is not intercepted. (doc)
This answer from Alex Martelli for more details.