STOP RUN is a Cobol construct. Other languages have similar, if not identical, constructs. The C language, for example, has 3 possible constructs:
- The return statement in a"main" function.
- A "main" function runs out of statements.
- The exit() library function.
OS/360 Assembler programs are effectively run as a subroutine from the operating system. Like C "main" functions they exit using the RETURN macro. Most beginners do not know this, but when a program called by the operating system, and that includes programs entered by OS services like the LINK macro, the program "returns" to an SVC 3 instruction which completes termination of the program.
Termination of a "main" program that uses a a run time library is usually handled by the library, and it attempts to perform most of the services discussed in the next paragraph.
"Full" termination of an Assembler "main" program by the operating system is actually quite involved, This is also done when a program terminates with an ABEND. The major service performs a CLOSE for any OPEN datasets. This can lead to the dreadded IEC999I message when the DCB or ACB .data area has been deleted or hopelessly damaged. The other major service is to cleanup allocated storage. In systems with complex storage maps like MVS this can be quite involved.