[python] Catching KeyboardInterrupt in Python during program shutdown