Waiting for subshell to terminate