This page applies to Harlequin v13.1r0 and later; and to Harlequin Core but not Harlequin MultiRIP
When Harlequin Core terminates, it calls SwTerminating just before shutting down:
void SwTerminating(int32 code, unit8 * string)
The parameter code is 0 for successful termination or non-zero if exiting due to some error. The string describes the error, if any.
When the Harlequin Core reboots (for example, when the quit operator in systemdict is executed), it calls SwReboot: void SwReboot (void)
The implementation should then do any necessary actions.