I'm a software engineer in my 40's. I also worry about ageism.
I don't want to victim blame. There is probably discrimination. But I think the older developers have some responsibility in defeating ageism.
I know a few SWEs who are older than me. They are already feeling the burnout of learning the new languages, frameworks, technologies every 3-4 years. Some of them are set in their ways thinking, "why would you need anything else other than C++/Java/etc.?" They grumble every time they are forced to learn something new. They have a point. After working in the industry for 15+ years, I empathize. But in this industry, that's unfortunately not the right attitude to have.
Another problem I see with older engineers is they are intimidated by the younger kids. I get it. When I interviewed some fresh grads, they seemed extremely talented and smart. I felt intimated by how much they knew. Some of the old guys lose confidence because of that. One old engineer who got laid off gave up looking for another job and faced early retirement. He told me he can't compete with the younger kids who already know all the new technologies and techniques.
Besides skills, I think it comes down to your attitude and how you relate to your younger co-workers. Being in my 40's, I still can relate to the kids. I try to bring a "young" energy. I'll see if I can keep this up into my 50's and maybe 60's.