Fix deadlock on process.wait()