Replace and close-app-and-suspend scripts improvements.