Corrected undefined variable in shutdown function causing recursive erro...

...r handling behaviour.