If you've wondered how to write code that waits for a process to finish before terminating it, here's the answer