I am 67, and I've been writing code at least sporadically since I was maybe twenty. I am still employed part-time as a programmer and system administrator. What happens in industry, often, is that people start as programmers but then get shunted off into other areas and "lose their touch" at coding and just willingly never go back to it. I deliberately maneuvered in several situations so that I could still touch code.
There is also agism in the software industry, and it is based on a mistaken premise that longer hours means higher productivity. Older people learn that it is not wise to (at the behest of an employer) burn themselves out writing code, and in my opinion, as I aged and was no longer willing to work outrageously long hours, I made up for it in several ways, with judgement grown due to wide experience.
Over the years, I also got better at teamwork. The programming profession, in my opinion, tends to attract people who are loners (sort of the stereotypical "tech geek"); programmer training also probably does not emphasize or teach teamwork. But most workplaces require maximum teamwork. Software managers often are either techies lacking good people skills, or people persons lacking tech skills. The larger software companies (Microsoft, Amazon, Google, etc) probably avoid this, but I'm speaking of middle range companies where "the rest of us" work. I worked in telecom, big pharma, academia, and science (biology) areas.
The last decade of my career, I was lucky to land a job working for biologists who valued my ability to get things done at every level, from sysadmin and user interfaces to web dev to number crunching. They didn't pay well, but they did treat me well and sometimes even said thank you. I had such a long queue of fires needing to be put out that I could never get it all done, but I was pretty good at prioritizing, organizing and communicating, and I thrived at that job.
Here's my view, as an older person, on coding and age:
* the young tend to be fearless and, if healthy, willing to work very long hours to the point of burnout; certain industries such as gaming exploit this, as do the large corporations
* older programmers can make up for lesser endurance by dent of experience, if they have bothered to keep abreast of developments and continue working regularly with code
* an ideal "team" of programmers will have both youngsters with their stamina, enthusiasm and lack of fear of change, and older programmers who've been through the fire, understand maintenance and performance hazards, and may have developed more people skills
This is all based on generalizations, which are maybe obnoxious and will not apply to every person or situation.