Refactor CFSocket callbacks to call Process.terminateRunLoop()
Refactor CFSocket callbacks to call Process.terminateRunLoop()

This fixes a data race between setting `process.isRunning = false`
and then calling `CFRunLoopSourceInvalidate(process.runLoopSource)`.
Process.waitUntilExit() may wake up and clear .runLoopSource which
results in a fairly common crash on Windows.

Put this logic in a common method to reduce drift between the
Darwin / Linux and Windows code paths.

Co-authored-by: Saleem Abdulrasool <d3629432f14a71b62e796d32d075121c69cf67de@compnerd.org>

apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation