SBCL provides hooks into the system initialization and exit.
— Variable: sb-ext:*init-hooks*
This is a list of functions which are called in an unspecified
order when a saved core image starts up, after the system itself has
been initialized. Unused by sbcl itself: reserved for user and
applications.
— Variable: sb-ext:*exit-hooks*
This is a list of functions which are called in an unspecified
order when sbcl process exits. Unused by sbcl itself: reserved for
user and applications. Using (QUIT :recklessly-p T), or calling
exit(3) directly will circumvent these hooks.