wait for process exit with timeout