I have had an Alcolapia which produced eggs and a brood as a female, become a male, when all males in the colony aged out.
Here she is carrying a mouthful of eggs as a female.
a few months later when all males died, she changed gender , changed color, and even some body shape, and spawned with an older female.
This species is from Lake Natron a soda/highly alkaline lake, that is more saline than the ocean, it is shallow, and conditions are very harsh, water temps in the lake can hit above 90'F, so its no wonder these fish have adopted some extreme measures to promote a continuation of the species.
I believe this genus of cichlids are the only fish that survive in Lake Natron and surrounding alkaline desert bodies of water.
some of her fry below