Killing an Application with Terminal
From Mac Guides
For example, you could be trying to connect to your computer from another computer, but VNC may not be working. In this case, the VNC server program could be the culprit, and you may want to kill it in the command line.
To do this, follow these steps:
- If on a remote computer, open an SSH connection to your machine (note: This requires SSH access to be enabled), otherwise just open the Terminal.
- At the command line, type: top -u and press enter
- Look for the program name, and then look to the left. You will see a number next to it. Jot the number down, that is the PID, or Process ID.
- Type q
- Type sudo kill PID (where PID is the number you jotted down). It will ask for your password, enter it.
- If the application is not responding to the kill command, sudo kill -9 PID will force the application to quit.
- To reopen the program, type open /Applications/[name].app, where name is the application's name. If the application is not in the Applications folder, you'll need to specify a different path. You can, of course, double click the application in the Finder in the traditional manner.
Instead of the kill command, it is possible to use the killall command, such as "killall iTunes" or "killall Safari". See "man killall" for more info.
Hint: You can also use the tab button to fill in a blank when manually typing names out, long or short. E.g. typing open /Applications, you can simply type open /App and press tab, it will fill out the rest.