In "Windows started picking up the really big pieces of TerminateThread garbage on the sidewalk, but it’s still garbage on the sidewalk", Raymond Chen states:
Originally, there was no
TerminateThreadfunction. The original designers felt strongly that no such function should exist because there was no safe way to terminate a thread, and there’s no point having a function that cannot be called safely. But people screamed that they needed theTerminateThreadfunction, even though it wasn’t safe, so the operating system designers caved and added the function because people demanded it. Of course, those people who insisted that they neededTerminateThreadnow regret having been given it.
The TerminateThread function has existed since the earliest Windows NT 3.1 pre-release build we have access to. Before this, Windows on MS-DOS was cooperatively multitasking on a single thread (no CreateThread function existed) and DOS extenders did not change this. So, the only people that could have "screamed" about needing TerminateThread were other Microsoft employees while Windows NT was still in development or possibly some very early external testers who Microsoft gave access to pre-release builds. In either case, the Windows NT designers clearly knew thread termination was problematic and had ample time to ensure this incorrect practice would never appear to be necessary in Windows NT before its final release. The Windows NT designers failed to address the root cause of why people likely felt they needed the TerminateThread function: the DLL_THREAD_DETACH routine of DllMain (as facilitated by the LdrShutdownThread function, which also existed in the same Windows NT 3.1 pre-release) breaking the resource ownership model for threads owned by a library. Further, early dependency loops between modules in active development by teams at Microsoft breaking linear module destruction was likely the cause for LdrShutdownThread and by extension LdrShutdownProcess, as it is reasonable to suspect that DLL thread initialization was a known hack disguising as a feature ever since it was added to Windows.