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
  • I would reinstall Chrome. Usually when I have a repeated issue like this it is due to some sort of configuration corruption. Dec 31, 2018 at 17:54
  • 1
    Reinstalling Chrome is completely irrelevant advice for this issue. Chrome needs to be stopped prior to the desktop environment being stopped. Essentially what is needed is a more up to date version of this answer: askubuntu.com/a/604709/7143 but for Ubuntu 18.04 where lightdm is no longer in use.
    – Maks
    Jan 10, 2019 at 23:41

2 Answers 2

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.

4
  • This didn't work, I tried with reboot and shutdown, and chrome still ask about to restore last session. any other advice ? Jan 12, 2019 at 20:17
  • sorry I didnt actually get a chance to fully test this when I posted, just ran the script directly and you are correct, it still seems to run too late. Looking at the docs it seems that the X server is already gone by this stage so thats probably why:help.gnome.org/admin/gdm/stable/configuration.html.en#scripting I'll need to do some more reasch to try to find a point early enough to do this
    – Maks
    Jan 12, 2019 at 22:50
  • 1
    actually this looks like some sort of bug in gdm3 as it appears that /etc/gdm3/PostSession/Default never actually gets run when shuting down! Its been reported in other questions: askubuntu.com/questions/1072616/… but Im not really prepared to take the derasitc measures suggested in that answer.
    – Maks
    Jan 13, 2019 at 22:48
  • Thanks @Maks for your time, effort and help in this, I will continue searching a solution. Jan 14, 2019 at 16:15
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

3

You must log in to answer this question.

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