60

In some cases killing a single tab/process doesn't do it and I need to close Chrome entirely. Since Chrome has multiple processes, how can I close all of them at once?

I know that...

pgrep chrome returns all the pids. What is a trick that would allow me to close all of them by feeding them to another command or merging them to a CSV file or something?

3

11 Answers 11

99

Try using pkill(1).

pkill chrome

4
  • just be aware that pkill might not be on all systems, but if you have pgrep, more than likely pkill exists as well.
    – kSiR
    Apr 14, 2010 at 19:36
  • 3
    for me this was case sensitive, I needed to write pkill Chrome Sep 30, 2014 at 18:04
  • 2
    Didn't work fork for me. Using pkill chrome It didn't close the main chrome process. It closed all the internal processes causing crashes on all extensions. Also, it caused some of the windows to not open on the next launch, causing loss of state :( Dec 6, 2016 at 6:34
  • 2
    @AlikElzin-kilaka - You might try explicitly killing the oldest Chrome process with something like pkill --oldest chrome
    – rinogo
    May 26, 2017 at 17:25
21
ps aux | grep chrome | awk ' { print $2 } ' | xargs kill -9

or

pgrep chrome | xargs kill -9

or

ps aux | awk '/chrome/ { print $2 } ' | xargs kill -9

The latter is more "elegant" as it will not pick up the actual pid for "grep chrome" inside of its ps listing

:-)

4
  • Is there any reason to use ps ... | instead of pgrep, even supposing you don't want to use pkill?
    – Cascabel
    Apr 14, 2010 at 19:36
  • 4
    It's also always polite to start with SIGTERM before escalating to SIGKILL.
    – Cascabel
    Apr 14, 2010 at 19:39
  • not really, only reason i threw the ps option out there is due to alot of my systems are bare bones meaning we dont have things like pkill pgrep
    – kSiR
    Apr 14, 2010 at 19:39
  • 1
    I agree, but one just asked to kill :-O s/-9/-1/g
    – kSiR
    Apr 14, 2010 at 19:39
6

Some systems may also have useful programs such as killall and pidof (which is actually provided by the System V killall5):

killall chrome
kill -9 `pidof chrome`

Both of these should accomplish what you are asking.

2
  • 1
    You shouldn't use -9 except as a last resort. Do kill PID first. Apr 14, 2010 at 20:52
  • killall also supports case insensitivity, for example: killall --ignore-case ChRomE would kill all Chrome processes. The option --ignore-case can also be shortened to -I. Unfortunately, pkill does not support case-insensitivity - at least on the Linux systems I have tried (but it does support -i for case-insensitivity on MacOS).
    – nonbeing
    Jul 1, 2018 at 17:31
2

/usr/bin/pkill --oldest --signal TERM -f chrome worked perfectly.

Source: https://unix.stackexchange.com/a/174451/6272

1
  • This should be the accepted answer.
    – nealmcb
    Jul 12, 2019 at 4:01
1

You should really just use pkill as jschmier suggests, but if you insist on pgrep, just use command substitution:

kill $(pgrep chrome)
2
  • would'nt kill pgrep chrome`` also work ;)
    – kSiR
    Apr 14, 2010 at 19:53
  • @kSiR: [a month late] yes, but $(...) is a great habit to get into so you can nest when you need to, and flip between matching delimiters in your editor.
    – Cascabel
    May 12, 2010 at 18:27
1

The easiest command is this one:

sudo killall chrome

This will, with administrative permissions, kill all processes that contain chrome in their name.

See man killall for more information...

1
  • 3
    Could you add a bit of explanation about how your answer works?
    – nhinkle
    Nov 1, 2011 at 4:43
1

Under Ubuntu, this is what worked for me:

pkill chromium

2
  • Of course also works just fine on a Mac via the VS Code terminal if for example doing some testing in Chromium (which can lead to allot of open instances) Feb 21, 2022 at 14:57
  • Oh, and on Mac it's usually "pkill Chromium" with a capital 'C' Feb 21, 2022 at 15:17
0

You can also try something like this:

ps -C chrome |cut -f 1 -d' ' | xargs kill
6
  • You shouldn't use -9 except as a last resort. Do kill PID first. Apr 14, 2010 at 20:53
  • good point. I updated my answer. Apr 15, 2010 at 7:08
  • No need for another pipe through cut; ps can do it itself: ps -o pid= -C chrome | xargs kill.
    – musiphil
    Sep 4, 2014 at 19:09
  • And it's a good habit to put -r in xargs: ps -o pid= -C chrome | xargs -r kill.
    – musiphil
    Sep 4, 2014 at 19:10
  • @musiphil: what is -r? Sep 4, 2014 at 19:11
0

This is the way:

kill -9 $(pgrep -d' ' -f chrome)
0

If you suspect there are other processes called chrome, yolou can use pgrep to search for processes with a given name.

0

To close all chrome instances on macOS:

pkill -9 "Google Chrome"

You must log in to answer this question.

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