Force quitting application to shut down computer

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!


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.

Contributor II

@fsteffy, I use the script on this post: I have computers that are scheduled to restart daily. Before the scheduled restart I created a policy that ran the script first.

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:


#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[@]}
	echo "Killing PID $i"
	kill -9 $i

exit 0