Synopsis

VOID WINAPI ExitProcess(
    UINT uExitCode
);

Terminates the calling process and all its threads.

Parameters

uExitCode Type: UINT – The termination status for the process. This value is passed to the parent process.

Return value

This function does not return.

Remarks

  • All threads in the process are terminated.
  • DLLs attached to the process receive the DLL_PROCESS_DETACH notification after all threads have terminated.
  • Windows will close any opened handles, flush buffers, and release resources.
  • Do not call ExitProcess from a DLL; use FreeLibrary or let the process exit naturally.

Example

#include <windows.h>
#include <stdio.h>

int main()
{
    printf("Process will exit with code 0.\n");
    ExitProcess(0); // Does not return
    // Unreachable code
    return 0;
}

See Also