addEndFunction (() -> ...) -- record a function for later execution, when the program is exited.
See also:
Code:
-- ../../../Macaulay2/m2/classes.m2:95-97 addEndFunction = g -> ( endFunctions = append(endFunctions,g); g)