IntuneBrew - MacOS Application Management for Intune
IntuneBrew LogoIntuneBrew

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.

  1. Download close-app-before-install.sh and save a copy for the app, for example close-outlook.sh.

  2. Set the variables at the top:

    APP_BUNDLE_ID="${APP_BUNDLE_ID:-com.microsoft.Outlook}"
    PROCESS_NAME="${PROCESS_NAME:-Microsoft Outlook}"
    QUIT_TIMEOUT="${QUIT_TIMEOUT:-30}"

    Look up the real values in the app's Info.plist (CFBundleIdentifier) and in Activity Monitor. QUIT_TIMEOUT is in seconds, from 1 to 120.

  3. Upload the app with the script:

    IntuneBrew -Upload microsoft_outlook -PreInstallScriptPath ./close-outlook.sh

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.

On this page