Avoid loops in the auto-closedown code