addEndFunction
addEndFunction (() -> ...)
-- record a function for later execution, when the program is exited.