Fix erase shutdown code