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.
ToIf you want to prevent reboot if you loginonce somebody logged in and then logout before timer is triggeredlogged out before timer is triggered you may try to stop are-users-logged.timer from ~./etc/profile.d/somescript.sh with something like sudo systemctl stop are-users-logged.timer. But i guess it is maybymaybe problematic if user is not root due password asking.
Better create some file in /tmp with echo from ~./etc/profile.d/somescript.sh to indicate you aresomebody was logged and check in your script_to_check_logged_users if it exists and skip shutdown.