fixed bug in shutdown sequence