When processes and applications hang in OS X, sometimes the only way to re-gain functionality is to force-quit them. For applications like Word or Safari, perhaps the simplest approach is to use Apple’s force-quit window, which can be invoked from the Apple menu, or by pressing the Option-Command-Escape hotkey. For background processes, scripts, and commands that generally run in the background, you will have to use alternative means.
One such option is to use Apple’s Activity Monitor program to view all running processes and identify ones that are hung up, and then select and force-quit them there; however, you can also use the Terminal to do this, if needed.
There are three commands that you can use to kill any process in the Terminal, using either its process ID (PID) or its name.
If you know the ID number of the specific process you would like to kill, then you can simply type “kill PID” or “sudo kill PID” to target this process and terminate it. This might be necessary as part of troubleshooting if you see this process ID listed with errors in the console or in other areas where you are monitoring the background activity of your Mac.
If you do not know the ID number of the specific process you would like to kill, then you can use its process name with the “killall” command. For example, if your Dock is hanging so when you hover your mouse over it you see the spinning color wheel cursor, you can kill and relaunch the Dock by typing “killall Dock” in the Terminal.
While the “kill” and “killall” commands should suffice for most purposes where you want to force-quit a process, another way to kill a process is to use “pkill,” the benefit here being you can kill processes using partial names and wildcard characters, instead of having to specify the entire name. This may be particularly useful if you have a program running that has various satellite processes and helper applications launched, which are all similarly named. For example, if you want to quit the QTKitServer process that runs as a plugin for Safari, this will launch in numerous instances with unique IDs appended to each instance name; however, they will all begin with the name “QTKitServer…” To kill all of these, you simply need to run “pkill QTKitServer*” and they will all be shut down.
If these processes continue to hang and show unwanted behavior, especially after restarting or logging out and back into your accocunt, then you will need to look into other approaches for solving the issue at hand.