Kill an application from AppleScript


on forceQuit(appName)

set pid to word 1 of (do shell script ("ps -xo,pid,command | grep "" & appName & "" | head -n 1"))

do shell script ("kill -9 " & pid)

end forceQuit

forceQuit("Clock")

From another user… i suggest changing that to “ps -xwwo,pid,command …” to avoid a problem where commands with very long path names are truncated, causing the grep to fail.