Close an app before updating
Ask a running macOS app to quit before Intune installs its PKG update, using a pre-install script.
Installing over a running app can fail or leave it in a broken state. The IntuneBrew repository includes a pre-install script that asks the app to quit before a PKG update is installed, and postpones the installation if it doesn't.
-
Download
close-app-before-install.shand save a copy for the app, for exampleclose-outlook.sh. -
Set the variables at the top:
Look up the real values in the app's
Info.plist(CFBundleIdentifier) and in Activity Monitor.QUIT_TIMEOUTis in seconds, from 1 to 120. -
Upload the app with the script:
What the script does
It runs as root, asks the app to quit normally in the signed-in user's session, and waits. It never force-quits. If the app is still running afterwards, because of unsaved work, another signed-in user, or an app that relaunches itself, the script fails so that Intune postpones the installation instead of installing over the open app. Intune retries on a later check-in.
Good to know
- Pre-install scripts only work for PKG apps. IntuneBrew ignores them for DMG apps.
- Test on a pilot Mac, including with an unsaved document open.
- Ask users to save and quit before your maintenance window; a script can't guarantee the app closes.