Improves shutdown sequence