How to catch SIGTERM in a Linux console app

Hi all,

i wrote a linux console app (rasperry pi, ARM), but i dispair on a simple thing:
If my app is terminated by a SIGTERM-signal (via CLI kill or via systemctl-daemon or via shutdown/reboot), i have to do some simple, short things (setting a output-pin, closing pigpio-lib, writing status to a file).
In Visual Basic there is a Unload-Event which is fired before the programm is closed and allows me to execute such things.

How can i do that with XoJo?

Please check SignalHandlerMBS class in MBS Xojo Util Plugins.