Improve server tear-down handling