Quit All Applications

Here’s a script I came up with for quitting all running dock applications (except Finder or Script Editor):

-- get list of open apps
tell application "System Events"
	set allProc to displayed name of (every process whose background only is false) as list
end tell
-- quit each app
repeat with eachProc in allProc
	set eachProc to eachProc as text
	if eachProc ≠ "Finder" then
		if eachProc ≠ "AppleScript Editor" then
			tell application eachProc to quit
		end if
	end if
end repeat

Or…:

		
-- get list of open apps
tell application "System Events" to set theapps to name of every application process whose visible is true and name is not "Finder"
		set keepapp to {"AppleScript Editor"}
-- quit each app
		repeat with closeapp in theapps
			if closeapp is not in keepapp then quit application closeapp
		end repeat

And if you want keep other apps, example:

		set keepapp to {"AppleScript Editor", "Xcode", "Safari", "iTunes"}