Reboot Pi with script

Solved for my part. The solution can be seen here (the part that isn’t working is to stop Hass before the reboot): Why isn't this shutdown/restart setup working?