What process of Google Chrome to kill to close window from terminal?

129,971

Solution 1

For the record, killing a process from Terminal isn't considered as "safely closing Google Chrome".

To kill the entire browser, you can run killall google-chrome-stable or (in this example) kill 2706 (note how the parent PID is 1, and all of the other processes stem down from this process).

To kill a tab, I can tell that process 3038 is a tab, but not which or what tab. You can run kill 3038 to kill the process running the tab, but note that the tab itself will still be open (but the content will be replaced with a blue screen).

Solution 2

If you don’t want to see “Google Chrome didn't shut down correctly. To repoen ...”, then it is important to signal only the root of the chrome process tree, like so:

pkill --oldest chrome

See full explanation. wmctrl -c (great program) only works with some window managers like Unity, and it only closes one window at a time so you would need a loop.

Solution 3

You can stop all of them with a single command:

sudo killall chrome

Then to prevent it from doinng this in the future, go into Settings, pick Advanced, and near the bottom you will find a switch where you can set it to NOT allow background processes to run when the program exits. Shut it off.

Solution 4

You also have an option to close the window using window manager control, but for it, you have to install a small package (tested on 14.04)

sudo apt-get install wmctrl

This procedure will simulate a click on then X button as you wished before.

wmctrl -c "Google Chrome"

The only drawback for chrome is that if the page asks for exit confirmation (like askubuntu when editing a post) this confirmation will be shown instead of the window closing.

The "Google Chrome" parameter can be swapt for any text in the window title and you can create a .sh file of this command and use it whenever you wish (in my case i wanted to simulate a windows 8 drag bottom close window feature using ccsm and hot conners)

Solution 5

As another option without using the command line is:

  1. Show Applications > System Monitor
  2. Go to the process name chrome
  3. Right click on it and choose End (or Kill)

    enter image description here

Share:
129,971
udiboy1209
Author by

udiboy1209

Updated on September 18, 2022

Comments

  • udiboy1209
    udiboy1209 almost 2 years

    Google Chrome usually has 8 to 9 processes running, even though only one window is open. Which one of these processes do I kill to safely close the Google Chrome window?

    Here is my ps -Af | grep chrome output:

    1000      2706     1  2 23:01 ?        00:00:52 /usr/bin/google-chrome-stable
    1000      2713  2706  0 23:01 ?        00:00:00 /usr/bin/google-chrome-stable
    1000      2714  2706  0 23:01 ?        00:00:00 /opt/google/chrome/chrome-sandbox /opt/google/chrome/chrome --type=zygote
    1000      2715  2714  0 23:01 ?        00:00:00 /opt/google/chrome/chrome --type=zygote
    1000      2719  2715  0 23:01 ?        00:00:00 /opt/google/chrome/nacl_helper
    1000      2720  2715  0 23:01 ?        00:00:00 /opt/google/chrome/chrome --type=zygote
    1000      2839  2706  0 23:01 ?        00:00:08 /opt/google/chrome/chrome --type=gpu-process --channel=2706.3.250838429 --supports-dual-gpus=false --gpu-driver-bug-workarounds=0,1,27 --disable-accelerated-video-decode --gpu-vendor-id=0x1002 --gpu-device-id=0x6760 --gpu-driver-vendor=ATI / AMD --gpu-driver-version=13.30
    1000      2843  2839  0 23:01 ?        00:00:00 /opt/google/chrome/chrome --type=gpu-process --channel=2706.3.250838429 --supports-dual-gpus=false --gpu-driver-bug-workarounds=0,1,27 --disable-accelerated-video-decode --gpu-vendor-id=0x1002 --gpu-device-id=0x6760 --gpu-driver-vendor=ATI / AMD --gpu-driver-version=13.30
    1000      3038  2720  1 23:08 ?        00:00:28 /opt/google/chrome/chrome --type=renderer --lang=en-US --force-[...very long options list]
    1000      4505  4441  0 23:40 pts/0    00:00:00 grep --color=auto chrome
    
    • saiarcot895
      saiarcot895 about 10 years
      By "Google Chrome window", do you mean one tab in Chrome, or the entire browser?
    • udiboy1209
      udiboy1209 about 10 years
      @saiarcot895 The entire browser.
    • udiboy1209
      udiboy1209 about 10 years
      If it is possible to close only a tab, please include that in the answer too.
  • udiboy1209
    udiboy1209 about 10 years
    I thought using kill was equivalent to pressing the 'x' button. What's the difference?
  • saiarcot895
    saiarcot895 about 10 years
    No, using kill or killall instantly terminates the process(es). It doesn't give the chance for applications to do what they normally do when closing. In the case of Chrome(ium), this can mean saving the profile, settings, and history and doing a few database transactions (I'm not sure what the full list is). Note that this applies to all processes.
  • Requist
    Requist over 9 years
    in 14.10 (or different Chrome version) the naming is changed. However 'pkill --oldest chrom*' will do the job for both.
  • saiarcot895
    saiarcot895 over 8 years
    Yes, I believe using the signal 15 (SIGTERM) gives them a chance to save their info.
  • MChaker
    MChaker over 7 years
    killall chrome worked for me on ubuntu 16.04
  • matt freake
    matt freake over 4 years
    @saiarcot895 it would be good to know why it isn't "safely closing"