Force quitting application to shut down computer

fsteffy
New Contributor

Has anybody successfully forced quit an application that a student left on and 'didn't save' their work so the computer could be shut down?

some apps are notoriously bad at quitting when there's something they think needs to be saved and this prevents the Mac from shutting down.

Any help would be appreciated!

4 REPLIES 4

alexjdale
Valued Contributor III

It's absolutely possible, and directly killing the process (not sending a quit command to the app) works in every situation I've experienced.

Alternately, "shutdown -r now" will force an immediate restart regardless of what's running.

joethedsa
Contributor II

@fsteffy, I use the script on this post: https://www.jamf.com/jamf-nation/discussions/17649/force-quit-all-apps-script. I have computers that are scheduled to restart daily. Before the scheduled restart I created a policy that ran the script first.

tkimpton
Valued Contributor II

@joethedsa can you post you code, the script on the link provided does not work.

@tkimpton, Sure thing.  Here is the one that I use:

#!/bin/bash

#Force quit all non-essential applications


declare -a killPIDs
killPIDs=$(ps axww -o pid,command | grep -v bash | grep [A]pplications/ | grep -v /bin/sh | grep -v [C]asper | grep -v [J]amf | grep -v [S]elf\ Service | grep -v [M]cAfee | grep -v [V]ZAccess* | grep -v grep | awk '{print $1}')
Kill said processes.


for i in ${killPIDs[@]}
do
	echo "Killing PID $i"
	kill -9 $i
done

exit 0