Wait for a process identified by PID to terminate