Ubuntu – Want chrome close normally when shutdown or reboot ubuntu 18.04

18.04google-chromerebootscriptsshutdown

Problem: When I reboot or shutdown ubuntu, and have chrome opened, I think chrome close normally, but not, and after start ubuntu and reopen chrome it say: chrome has closet anomaly, and you want to restore tabs?(something like that.).

Want: close chrome normally before shutdown or reboot, and start normally without error message about anomaly close.

I try to create an init script and it didn't work, I reboot or shutdown Ubuntu with chrome opened, then start chrome and test open chrome and see if it closed normally, but it din't.

Script for close Chrome

#!/bin/sh
killall -1 chrome

Path of script

# path script
etc/init.d/closeChrome

How I create

# how I create script for reboot and shutdown
sudo ln -s /etc/init.d/closeChrome /etc/rc0.d/K00closeChrome
sudo ln -s /etc/init.d/closeChrome /etc/rc6.d/K00closeChrome
sudo chmod a+x /etc/init.d/closeChrome

Update 31/12/2018: The script does its function, it execute before Ubuntu shutdown, but I think chrome close before script starts, maybe Ubuntu close sessions and their programs.

Upate 05/01/2019: Try to reinstall chrome.

Upate 06/01/2019: try remove selected from "Settings -> System -> Continue running background apps when Google Chrome is closed"

Update 16/01/2019: Try to use /etc/gdm3/PostSession/Default but gdm3 Default never executed on shutdown computer.

Best Answer

Update 1 Mar 2019

This bug has now been marked as fixed and expected to ship in Chrome 74 or later:


Taken from this answer, you need to add the following line into your /etc/gdm3/PostSession/Default:

killall -HUP chrome

Note you will need root (eg. sudo) access to edit that Default file.

Related Question