The C$EXITINFO library routine returns information about an exit from an END procedure in the declaratives.
CALL "C$EXITINFO" 
    USING EXIT-MESSAGE, EXIT-CODE, OS-EXIT-CODE, SIGNAL-NUMBER
               	 | EXIT-MESSAGE Alphanumeric | Contains the lines of text that the runtime outputs to the error file or shutdown message box. Each line of text is separated by a newline character H'0A'. | 
| EXIT-CODE Numeric (optional) | Contains one of the following codes (listed in 
                                 					 lib/sub.h):     1     COBOL_EXIT_PROGRAM
    2     COBOL_REMOTE_CALL
    3     COBOL_STOP_RUN  
    4     COBOL_CALL_ERROR
    5     COBOL_SIGNAL
    6     COBOL_FATAL_ERROR
    7     COBOL_NONFATAL_ERROR
    8     COBOL_DEBUGGER   | 
| OS-EXIT-CODE Numeric (optional) | Contains the value that the process passes to the system exit routine | 
| SIGNAL-NUMBER Numeric (optional) | This is always 0 on Windows. On UNIX, it contains the signal number if EXIT-CODE is 5 (COBOL_SIGNAL). |