I apologize if this is the wrong forum for this question -- if so, could somebody please point me to the correct one?

I'm a professor who recently started advising graduate students, and I'm trying to find a way to feel good about the time I spend on my students when they leave academia. I devote loads of time and energy into helping my students reach their full potential, and giving them every benefit of my experience, in part because this will contribute to the development of mathematics. But I'm having trouble coming up with a justification for putting so much effort into mentoring students, if the students will wind up leaving academia. Probably many people on this forum have thought through this and come up with some kind of answer, and I would love to hear about these.

Let me clarify that I understand that advising grad students is part of my job. But there are only so many hours in the day, so I need to find a balance between time spent mentoring students and time spent doing research, writing papers, etc. So far I've made my students my top priority, but then when they leave academia, I have a hard time justifying to myself that I should have sacrificed effort on all other fronts in order to help the student develop.