> Windows Syscalls
ntoskrnl.exeT1562.001T1055.003T1106

NtTerminateThread

Terminates the specified thread with the supplied exit status. NULL handle terminates the current thread.

Prototype

NTSTATUS NtTerminateThread(
  HANDLE   ThreadHandle,
  NTSTATUS ExitStatus
);

Arguments

NameTypeDirDescription
ThreadHandleHANDLEinHandle to the thread to terminate. NULL means the current thread.
ExitStatusNTSTATUSinNTSTATUS exit code recorded against the thread.

Syscall IDs by Windows version

Windows versionSyscall IDBuild
Win10 15070x53win10-1507
Win10 16070x53win10-1607
Win10 17030x53win10-1703
Win10 17090x53win10-1709
Win10 18030x53win10-1803
Win10 18090x53win10-1809
Win10 19030x53win10-1903
Win10 19090x53win10-1909
Win10 20040x53win10-2004
Win10 20H20x53win10-20h2
Win10 21H10x53win10-21h1
Win10 21H20x53win10-21h2
Win10 22H20x53win10-22h2
Win11 21H20x53win11-21h2
Win11 22H20x53win11-22h2
Win11 23H20x53win11-23h2
Win11 24H20x53win11-24h2
Server 20160x53winserver-2016
Server 20190x53winserver-2019
Server 20220x53winserver-2022
Server 20250x53winserver-2025

Kernel module

ntoskrnl.exeNtTerminateThread

Related APIs

TerminateThreadExitThreadNtTerminateProcessNtSuspendThreadRtlExitUserThread

Syscall stub

4C 8B D1            mov r10, rcx
B8 53 00 00 00      mov eax, 0x53
F6 04 25 08 03 FE 7F 01   test byte ptr [0x7FFE0308], 1
75 03               jne short +3
0F 05               syscall
C3                  ret
CD 2E               int 2Eh
C3                  ret

Undocumented notes

Pleasantly stable SSN — 0x53 from Windows 10 1507 through Windows 11 24H2 — because NtTerminateThread sits early in the alphabetical SSDT and few preceding routines have been added. The kernel implementation funnels through PsTerminateThreadByPointer, decrements the rundown reference, signals waiters, and ultimately reaps the thread object. When called with a NULL handle the kernel substitutes the current thread (ZwCurrentThread / (HANDLE)-2 semantics).

Common malware usage

Three classic patterns. (1) Race-stopping: terminate an EDR scan thread mid-scan so a write to disk completes before re-scan. (2) Stub cleanup: after hijacking a thread (NtSetContextThread to shellcode), the payload eventually calls NtTerminateThread(NULL, 0) to discard the hijacked thread without invoking the now-corrupted return chain. (3) Suicide on tamper detection: many crypters call NtTerminateThread on themselves the moment they detect an attached debugger to deny the analyst a live process. Often paired with NtTerminateProcess for a full self-wipe.

Detection opportunities

Self-termination is invisible noise. Cross-process termination of *another* process's thread is rare and high-signal — most legitimate code calls NtTerminateProcess instead. Capture via Microsoft-Windows-Threat-Intelligence ETW (EtwTiLogTerminateThread on some builds) or a PsSetCreateThreadNotifyRoutine watching for unusual TerminationStatus values from non-system PIDs. On modern Windows the most useful signal is *correlation*: cross-process NtOpenThread followed within milliseconds by NtTerminateThread targeting a security product PID.

Direct syscall examples

asmx64 stub (stable across builds)

; SSN 0x53 — stable Win10 1507 .. Win11 24H2.
NtTerminateThread PROC
    mov  r10, rcx
    mov  eax, 53h
    syscall
    ret
NtTerminateThread ENDP

cSelf-terminate after payload

// At the tail of injected shellcode: cleanly exit the hijacked thread so the
// stack/return-address damage from the hijack never executes.
static VOID PayloadEpilogue(VOID) {
    // ... shellcode work ...
    typedef NTSTATUS (NTAPI *pNtTerminateThread)(HANDLE, NTSTATUS);
    pNtTerminateThread NtTerm = (pNtTerminateThread)
        GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtTerminateThread");
    NtTerm(NULL, 0);   // NULL = current thread
}

rustDirect syscall, current thread

use std::arch::asm;

#[inline(never)]
unsafe fn nt_terminate_current_thread() -> ! {
    asm!(
        "mov r10, rcx",
        "mov eax, 0x53",
        "syscall",
        in("rcx") 0usize,    // ThreadHandle = NULL -> current
        in("rdx") 0usize,    // ExitStatus  = 0
        options(noreturn),
    );
}

MITRE ATT&CK mappings

Last verified: 2026-05-20