The word "safe" purely depends on what you consider safe. For some it's a strong password protecting their
account, while for others it's a rectangular steel safe, standing 42 inches tall, 24 inches wide, and 20
inches deep, weighing about 450 pounds, with a matte dark graphite gray powder-coated finish resistant to
scratches and moisture. Its door is 4 inches thick, reinforced with solid steel plating, and filled with a
concrete composite fireproof barrier. BUT in our case it's preventing yourself from locking yourself out of
your own PC or having to turn off your PC just to stop a macro.
The best practice is to always add a way to forcefully stop your code in case you need to pause it or you've
done the test you needed to do and now you want to fix the issue or improve it in the code. While I myself had
such issues once or twice, I could see how a beginner could also easily make them. For example, moving your
mouse to specific coordinates and clicking there multiple times per second in a "while True" loop and
forgetting to add a break statement at any point would cause the user to have to think outside the box and
find a solution or just restart their PC using the power button.
Adding simple code that would allow you to exit your macro at any time is an absolute must-have when creating
macros. You can add this simple code below to add an ON/OFF switch with forced exiting added to it too:
But adding it alone into your code wouldn't do much; you need to add it into a separate thread to make it work
at any time and never be blocked by other processes. This way, even if you get stuck in an infinite loop, you
will still be able to easily exit the macro. All my macros use the exact same way of pausing and force
exiting, so you could look into it yourself and see how it's done in an actual example.