baur,
The program that I've written simply runs in /etc/rc, daemonizing itself can catch the SIGTERM signal.
Upon shutting down the system, the SIGTERM signal is send to all processes, thus the program that I've written catches the SIGTERM signal.
After I've catched the SIGTERM, I call...