Ensure that `open(::Function, ::Cmd)` waits for termination (#44078)
On Windows, we observed occasional issues where an error within the
function callback to the `open(::Function, ::Cmd)` method would cause
problems due to assuming that the opened process had finished by the
time the `open()` call was finished. In most cases this was true,
however on Windows, it was found that we need to explicitly `wait()`
upon the process object to ensure that all file handles held by the
subprocess were properly closed by the time `open()` is finished.
Co-authored-by: Dilum Aluthge <dilum@aluthge.com>