I\'m using PyPI\'s keyboard module to monitor whether the user wants to stop execution of the program:
print(f\'Press ESC to stop or any other key to continue