Fixed the order of manager shutdown