The module sys delivers a method, to terminate a python program:
>>> import sys
>>> sys.exit()
alternatively:
raise SystemExit
sys.exit() raises the SystemExit exception.
If it is not handled, the Python interpreter exits; no stack traceback is printed.
If the associated value is a plain integer, it specifies the system exit status; if it is None, the exit status is zero; if it has another type (such as a string), the object’s value is printed and the exit status is one.
Another way to exit: quit()