It's a good idea to catch and re-elevate KeyboardInterrupts, so that you could nonetheless destroy the program working with Ctrl-C. Logging is outside the house the scope from the question, but a great selection is logging. Documentation for that sys and traceback modules. I'm seeking to write a PowerShell script https://helpmehigh.com/