DosExit is issued when a thread completes executing. The current thread or process ends.
DosExit allows a thread to terminate itself or be terminated by another thread in its process. If action is 0 and the specified thread is the last thread executing in the process, the process ends. If action is 1, the process ends.
The system can start threads on behalf of an application. Thus, if the intent of DosExit is to terminate the process, a value of 1 should be specified for action to end all the threads belonging to the process.
Do not end thread 1 without ending the process. Thread 1 is the initial thread of execution, not a thread started by a DosCreateThread request. When thread 1 ends, any monitors or signal processing routines set for this process also end. To avoid unpredictable results, DosExit should be issued with a value of 1 for action to ensure that the process ends.
When a process is ending, all but one thread is ended, and that thread executes routines whose addresses have been specified with DosExitList. After resources have been released by the exit list routines, this thread and all other resources owned by the process are released.