Exit code (def_exit)¶
What it does: Defines the code to be executed when the program exits.

Inputs¶
exit_code: commands for final cleaning.
Output¶
- None (statement block).
When to use it¶
- Saving data, shutting down peripherals and safely freeing resources.
- Preparing device for restart or stop.
Tips and pitfalls¶
- Don't put long blocking operations in the termination section.
- Close open files and put outputs in a safe state.
Generated Python example¶
def on_exit():
pwm22.deinit()
print("Program is ending")