Small utility to wait for a process to finish