how to run code when program is stopped python code example Example: how to stop the program in python import sys sys.exit()