An exit routine (also called "exit exec") is a special purpose IDF macro, which runs when certain events occur.
For general instructions on writing a REXX macro, see REXX linkage considerations. For instructions on writing a compiled-language exit routine, see Writing a compiled-language IDF exit routine.