move shutdown into done block