I wrote an applescript that turns on my lights. I exported it as an application with the name "LightsOn", and it appears with that name in activity monitor.

LightsOn in Activity Monitor

Under certain circumstances, this app gets stuck. I can force quit it from Activity Monitor, but I want to be able to do so from a script. killall LightsOn doesn't work; I'm told that no matching processes belonging to you were found.

How can properly force quit this app from the terminal? Or, how can I discover the appropriate name for killall?

  • 1
    pkill -9 -f LightsOn will do it! Oct 11, 2018 at 2:47
  • @user3439894 Yay, that was easy! I've been trying to figure out how to do this for ages. If you make that an answer, I'll accept it! Oct 11, 2018 at 3:37
  • As requested, I posted an answer covering my comment to you that worked over the other answer which originally didn't, but has since been edited. I added additional information to cover why killall LightsOn doesn't work. Oct 11, 2018 at 10:35
  • Instead of needing a kill why not code a timeout in your app?
    – ʀ2ᴅ2
    Oct 11, 2018 at 13:00
  • @ʀ2ᴅ2 Long story, but the short version is because (1) this is an invisible helper application, so it doesn't matter much, and (2) there's no good way to set a timeout for a shell script in an Applescript, and what is doable is finicky and error prone. Oct 11, 2018 at 14:20

2 Answers 2


The reason killall LightsOn doesn't work is because all running AppleScript application's process name is applet. For example, the executable path is:


In general and assuming the process(es) is(are) not hung, one could use killall applet however that will terminate all running AppleScript applications, and of course that may not be desirable.

When a process is hung, you'll need to use a KILL signal, e.g.:

killall -KILL applet

However, pkill is the way to go to easily target a specific AppleScript application and because it's hung... use a KILL signal, e.g.:

pkill -9 -f LightsOn


pkill -KILL -f LightsOn

Note in this instance, -9 is just another way of saying -KILL.

Now with pkill and using the -f option, one can use more of the full argument list, e.g.:

pkill -9 -f /Applications/LightsOn.app/Contents/MacOS/applet

Then there's no ambiguity as to which applet process one is targeting. One can use as much of the full argument list as one feels is necessary to target the correct process.

For example, pkill -9 -f LightsOn will terminate an AppleScript application named NoLightsOn, so always use enough of the full argument list to terminate the correct process.

For reference:

From the pkill man page:

 -f          Match against full argument lists.  The default is to match
             against process names.

From the killall man page:

 Some of the more commonly used signals:

 1       HUP (hang up)
 2       INT (interrupt)
 3       QUIT (quit)
 6       ABRT (abort)
 9       KILL (non-catchable, non-ignorable kill)
 14      ALRM (alarm clock)
 15      TERM (software termination signal)

Note that this is just a partial signal list and is used with many of the different utilities that can terminate a process. See the various manual pages of the utilities used for additional information.


Try this:

ps auxwww | fgrep -v fgrep | fgrep -i LightsOn

That should show you the matching process information.

You can also try pkill which should work like this:

pgrep -fl LightsOn

If that shows you the PID, then you can move on to pkill:

pkill -9 -f LightsOn

When you run pkill -9, you're not telling the application to terminate itself, instead you're telling the OS to stop running the program, no matter what the program is doing.

When app gets stuck sending the kill without specifying the signal #, it will automatically assign to it the signal <15>, which means asking the app to terminate it self, it can not do that while stuck.

  • You said, Try this: ps auxwww | fgrep -v fgrep | fgrep -I LightsOn, why!? when pkill -9 -f LightsOn will do it! Oct 11, 2018 at 2:49
  • pkill -fl LightsOn isn't killing the app on my machine. I seem to need the -9. Oct 11, 2018 at 3:39
  • @user3439894 The first command was never intended to kill the process, just to show its information, which might help explain why killall wasn't doing what was expected. pkill -9 is a blunt instrument, not a first step. IMO.
    – TJ Luoma
    Oct 12, 2018 at 0:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .