Kill a process by specifying its PID, either via a signal or forced termination.
Syntax kill [-s signal_name] pid ... kill -signal_name pid ... kill -signal_number pid ... kill -l [exit_status] Key -s signal_name A symbolic signal name specifying the signal to be sent instead of the default TERM. -signal_name A symbolic signal name specifying the signal to be sent instead of the default TERM. -signal_number A non-negative decimal integer, specifying the signal to be sent instead of the default TERM. -l [exit_status] If no operand is given, list the signal names; otherwise, write the signal name corresponding to exit_status. The following pids have special meanings: -1 If superuser, broadcast the signal to all processes; otherwise broadcast to all processes belonging to the user.
Some shells provide a builtin kill command which is similar or identical to this utility.
The kill utility sends a signal to the processes specified by the pid operand(s). Only the super-user can send signals to other users' processes.
Common Kill Signals Signal name Signal value Effect SIGHUP 1 Hangup SIGINT 2 Interrupt from keyboard SIGQUIT 3 Quit SIGABRT 6 Cancel SIGKILL 9 Kill signal SIGTERM 15 Termination signal - allow an orderly shutdown SIGSTOP 17,19,23 Stop the process
This is a BASH shell builtin, to display your local syntax from the bash prompt type: help kill or man kill
List the running process
PID TTY TIME CMD
1293 pts/5 00:00:00 MyProgram
Then kill it
$ kill 1293
+ Terminated MyProgram
Or to really really kill it
$ kill -9 1293
To close an application you can also send an applescript quit command:
$ osascript -e 'quit app "safari.app"'
"Love never dies a natural death. It dies because we don't know how to replenish it's source. It dies of blindness and errors and betrayals.
It dies of illness and wounds; it dies of weariness, of witherings, of tarnishings" ~ Anais Nin
Related macOS commands:
ctrl+z / ctrl+c - Suspend/Interrupt a program.
ps - List running processes (returns PID).
pkill - Kill processes by a full or partial name.
killall - Kill processes by name.
lsof - List open files.