         if case .timedOut = group.wait(timeout: .now() + 10) {
             XCTFail("timeout waiting for signals to be processed")
         }
+
+        // rdar://74356445: make sure the processes are terminated as they *sometimes* cause xctest to hang
+        processes.terminate()
     }
   #endif
 

                    let file = tmpdir.appending(component: "pidfile")
                    let waitFile = tmpdir.appending(component: "waitFile")
                    let process = Process(args: self.script("subprocess"), file.pathString, waitFile.pathString)
                    try process.launch()
                    guard waitForFile(waitFile) else {
                        return XCTFail("Couldn't launch the process")

                    let file = tmpdir.appending(component: "pidfile")
                    let waitFile = tmpdir.appending(component: "waitFile")
                    let process = Process(args: self.script("print-pid"), file.pathString, waitFile.pathString)
                    try processes.add(process)
                    try process.launch()
                    guard waitForFile(waitFile) else {
                        return XCTFail("Couldn't launch the process")
