The NASA astronaut corps is a mix of civilians and active duty military officers, so what happens when they leave first depends on which of those camps they fit into.
If they are active duty military, and do not retire from the military prior to leaving their astronaut position at NASA, they will go on to whatever assignment the military wishes to give them. For example, Susan Helms was a member of the Expedition 2 crew. She returned to Earth in August 2001. By 2...
Also read: Women of NASA get their own Lego set