Automated way to shutdown hub with security enabled?

I have an automated script to take backups with hub authentication enabled. It should be pretty easy to adapt it to shut the hub down.