pnd_run.sh: improve wait for app exit