Create two systemd units and one script.

First unit:

````
/etc/systemd/system/are-users-logged.timer
[Unit]
Description=Start check for logged users

[Timer]
OnBootSec=15min
Unit=shutdown-ifno-logged-users
[Install]
WantedBy=timers.target
````
runs `shutdown-ifno-logged-users.service` once after 15min from the boot.


Second unit:

````
/etc/systemd/system/shutdown-ifno-logged-users.service
[Unit]
Description=Shutdown if there are no logged users

[Service]
Type=oneshot
User=root
ExecStart=script_to_check_logged_users
````
starts your script to check logged users.

In your script parse output of `loginctl --no-pager list-users` or maybe even `who -q` and shutdown if there is no user logged.

To prevent reboot if you login and then logout before timer is triggered you may try to stop `are-users-logged.timer` from `~./profile` with something like `sudo systemctl stop are-users-logged.timer`. But i guess it is mayby problematic due password asking.

Better create some file in /tmp with `echo` from `~./profile` to indicate you are was logged and check in your `script_to_check_logged_users` if it exists and skip shutdown.