Wait for process to exit