What process of Google Chrome to kill to close window from terminal?
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
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).
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.
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.
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)
As another option without using the command line is:
- Show Applications > System Monitor
- Go to the process name
chrome
-
Right click on it and choose
End
(orKill
)