Create a systemd service and add this to the [Service] section:
[Service]
Exec=gnome-session-quit --logout --no-prompt
How to start a systemd service after user login and stop it before user logout
How create a service in linux that can handle queries?
Or you can also try the following, which probably won't work:.
@reboot sleep 60 && gnome-session-quit --logout --no-prompt@reboot sleep 60 && gnome-session-quit --logout --no-prompt ThisThis might help to wait 60 sec, if the session isn't fully loaded when the system starts, and the logout command might not work immediately for that reason.