2

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.

Update 10/05/2023: I found it is a bug of chrome: Issue 429404: Chrome didn't shutdown correctly every time after reboot

2 Answers2

2

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.

Maks
  • 545
0

Update 5 April 2022

My issue was similar but with Brave browser. After more than an hour of research on the internet and after reading the various comments, this solution is almost the right one.


Setup:

OS: Pop!_OS 21.10 x86_64
Kernel: 5.16.15-76051615-generic
Brave Browser 100.1.37.109
DE: GNOME 40.5


Sometimes we are directed to the /etc/rc6.d folder by creating the K99_script file without the .sh but this solution did not help me in my case. answer here

So I started to do the solution of But but it didn't work. So I looked if I had the same result by launching the command directly in a terminal and it was the case. And until I simply send the following command:

$ killall brave

Brave browser did not ask me to restore my tabs. So I confirmed what was the solution that worked with this command and it was Maks solution but without any argument.

Complete procedure

$ cat /etc/gdm3/PostSession/Default
# For add line before "exit 0"
$ sudo sed -i '/^exit 0.*/i killall brave' /etc/gdm3/PostSession/Default
$ cat /etc/gdm3/PostSession/Default

You can reboot and your browser won't ask you to restore tabs

When the user terminates his session, the PostSession script will be run. Again operation is similar to Init, PostLogin and PreSession. Again the script will be run with root privileges, the slave daemon will block and the $USER environment variable will contain the name of the user who just logged out and $DISPLAY will be set to the display the user used, however note that the X server for this display may already be dead and so you shouldn't try to access it. Also $X_SERVERS environmental variable is set and this points to a fake generated x servers file for use with the sessreg accounting program. source


if the problem persists it may be due to a browser extension : answer here

LinkPhoenix
  • 103
  • 6