Brave didn’t shut down properly [Workaround]

Brave didn’t shut down properly [Workaround]
Follow-up from Previous Workaround, didn’t work reliably.

Description of the issue:
It seems Brave does not properly shut down on reboots or shutdowns.
Possibly a timeout issue, where the system overrides the termination process, because it’s not patient enough, or Brave takes too long (milliseconds?) to save the session? or to close the windows?

How can this issue be reproduced?

  1. Shut down or reboot your linux system; having at least 1 brave window open
  2. Reopen Brave
  3. See the message “Brave didn’t shut down properly. (Restore Session Button appears)”

Expected result:
With session restore enabled, it should just restore the session without the error; however, it should properly close to do that, not just override the error.

Brave Version( check About Brave):
Any, for months now.

Additional Information:
Seen in this Forum on Mint, for me it’s Arch (derivative) btw.

Generally, Applications receive a SIGTERM on shutdown. As soon as I implemented a workaround, I no longer received the message.

In theory:
Instead of the system shutdown, run a script that does this in the following order:

  1. Kill brave with SIGTERM
  2. wait a second
  3. initiate shutdown

Now YMMV, and maybe someone may add a POSIX + sh compatible version, but on my system

pkill -TERM brave; sleep 1; reboot

does the trick. You can try it from a terminal first, and have your shutdown sequence instead of calling systemctl directly, call a script

~# nano ~/.local/bin/kill_brave_reboot.sh

that looks like

#!/bin/bash
pkill -TERM brave; sleep 1; reboot

and don’t forget to

~# chmod +x ~/.local/bin/kill_brave_reboot.sh

#worksOnMyMachineLol
You’re welcome if you suffer from this as well.

Bonus: my shutdown command works via rofi-power-menu and the edited line goes like:

# actions[reboot]="systemctl reboot"
actions[reboot]="/bin/bash kill_brave_reboot.sh"

I tried to edit this inline without script, but the pkill seemed to have issues with the arguments at/after the first semicolon or && I tried. Launching a subprocess was the most feasible for now.

If you want, you can play around with launching, then killing with
kill -s 9 brave
or
kill -s 15 brave
or
pkill -3 brave
or
pkill -30 brave

3 and 30 threw the error before restore, while 9 and 15 did not on my machine.
So I don’t know what brave does internally when receiving a signal from systemd, since, well systemd default should be a SIGTERM for all applications, and Brave is the only outlier for me. Surely something the devs should look into, but for me, for now, at least it’s no longer buggin me.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.