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