There are companies out there who value the experience of senior software engineers (and I mean real seniority, not the job title that you update to senior after 3 years in the field). Such companies will have a career ladder up to Principal or Distinguished engineer. You will have to share your knowledge, of course, but without having to give up coding and do people management, if you don't want that. I'm 39, happy…
Principal (even many Staff roles) at my company is reduced coding and many have direct reports, so YMMV. To stay coding, stay “senior” level.
As a Principal I do code less than I used to as Staff or Senior. But I still do a fair amount of coding (along with design, arch, mentoring/guiding). I've made it clear that I want to remain a hands on engineer, and my company has let me remain so.
Not everyone is so lucky to have a choice, but if you do -- In the end, its finding a place where you can get the balance that makes you happy.