Scholars have an afterlife in their students and publications. In some fields, journals and books, even, are meant for the authors, since the published work is rarely read--preprints, word of mouth, etc, dominating the influence of the published literature. In others, the work may have a lifetime of decades, and in others it may well be valuable fifty years hence (mathematics would seem to be of this sort).
Students will be affected by your mentoring as well as by your actual teaching. What you do in a class, or in office hours, what you happen to say, may well have lifetimes of impact and influence, although you are unlikely to know which of what you do is effective. If you have doctoral students or senior thesis students, you can readily make a big difference by just being attentive, encouraging, and providing the leadership for when students really need it. You can answer better questions than students ask. You can by your work and your discipline show some students how they might live.
Most scholars feel insufficiently recognized. I observe that the most prominent of them feel that others do not recognize their achievements sufficiently, and usually point to others who get credit for work for which they should be recognized. You may have students who will defend your achievements and carry on lifelong campaigns to be sure that others do not displace you. (Here I am thinking of the Yale mathematician Serge Lang's campaign re Andre Weil, Emil Artin, and others.) If at a lunch table, I put together two distinguished scholars, albeit from different fields, they may well end up talking about how one was a Jefferson Lecturer while the other counters about his Nobel prize! Keep in mind that the number of people in each field so recognized is likely to be many fewer than 10.
As for retirement, the big question is What next? There may be books to be written or fieldwork to be done or students needing your attention now that they have tenure. And if you have always wanted to write a novel, you may do that. At some point, the rigamarole of academic bureaucracy can become burdensome, or students seem uninteresting, or you have run out of energy to go at your standard pace. Or, you have been looking for an excuse to cut the demands made on you, and so retirement is a blessing.
Ideally, there should be a marketplace for those who are considering retirement or changing their jobs after 30 years. You move to another institution where your talents are just what they need. Tenure keeps people stuck in jobs they should have abandoned years ago.
Outside the marketplace, you volunteer, you attend to your extended family, you rest more, you write a novel or poetry or ...