Fixed the shutdown error

Moved the shutdown code to the mode maintenance so that shutdown will
happen after the flashes finish. Needed to add a shutdown delay upon
startup to keep the unit from shutting down right after waking up.