I wanted to have a small function that prints an error message and then terminates the program. When I changed the program termination method from sys.exit() to
sys.exit()