So this is a nuanced question and requires a detailed response. But the gist is that older folks don't necessarily cost more. I've seen many older folks continue to work as developers for most of their lives (albeit this is outside Silicon Valley). But for many older developers who continue on the technical track, they have accumulated a lot of experience building software and they do bring a lot to the table, in terms of design, or prescient thinking, or knowing the internals of certain stacks very very well. That kind of knowledge is certainly useful for firms that operate on scale, have systems that cannot tolerate downtime, and so on.
In other words, it depends on the individual.