Corrected undefined variable in shutdown function causing recursive error handling behaviour.