waits for process exit