The launcher process does not start the browser under a job object, so killing the launcher process (which is obviously the one whose handle you have) won't have any effect on the browser itself.
I suppose there are a few options here, but it really depends on effort and whether we want to add this functionality to Puppeteer/node or to the launcher process itself.
If we landed a change to the launcher process to use a job object, we could probably make this all Just Work (TM). I would add the caveat that we would only do this for Windows 8 and higher, so if Windows 7 matters, then this isn't an option.
Other options probably involve adding code (and possibly necessitating the addition of new dependent packages) to Puppeteer itself that call various Windows APIs to discover the browser process and terminate it:
- Puppeteer could use a different API that supports Windows job objects to start Firefox (again, has the same Windows 7 limitation as above);
- Using toolhelp for enumerating processes, finding the one whose parent is the launcher, and then terminating that;
FindWindow for resolving a Firefox window, obtaining its pid, and then terminating that (hard to distinguish between multiple instances of Firefox if that is a concern)