NTSTATUS
PsTerminateSystemThread(
IN NTSTATUS ExitStatus
);
PsTerminateSystemThread terminates a caller-created system thread.
PsTerminateSystemThread returns the STATUS_XXX supplied by the caller-created thread, usually STATUS_SUCCESS.
Drivers that create a device-dedicated thread call this routine, either when the driver is unloaded or when there are no outstanding I/O requests for the driver to process. For such a driver, PsTerminateSystemThread must be called in the context of the driver’s thread; that is, the driver-created thread must terminate itself by making this call.
Callers of this routine must be running at IRQL PASSIVE_LEVEL.