Keep better track of when external process threads are running to avoid crashes if the user closes a window at the wrong time.