Midlife iron status is inversely associated with subsequent cognitive performance, particularly in perimenopausal women.