Some of this is almost certainly due to low quality (middle) management; people who are unable to mentor or supervise someone coming up to speed in their company's technical ecosystem are infamous for playing buzzword bingo with resumes and not indefinitely not filling positions. It's a small leap from that to e.g. not being willing to manage someone significantly older than you.
Then there are entirely rational aspects: older programmers tend to cost more per unit of time. In the US past 39 in the US they can sue for age discrimination if fired (see e.g. http://en.wikipedia.org/wiki/Brian_Reid_%28computer_scientis... for the current best known example). Safest not to hire them in the first place, that's legally much easier to defend.
I've been hired entirely on the basis of FizzBuzz type tests when the hiring manager took an instant dislike to me. He tried to find a reason not to hire me (as reported by one of my references, who knew both of us, me very well) but went ahead and did it because it was the only way to save his company (I was the only one who passed the tests). He was just out of college with no management experience and I was 37 (I think age was a small but otherwise minor factor in all this).
So rationality can overcome a lot. But how many times have we seen managers make "irrational" project or company killing hiring and firing decisions? How many investors have preferred to have all of nothing instead of some of something?
There are many truly senior developers who can pass the FizzBuzz test who are never given the chance because of age. It isn't universal but age discrimination is real. And while it might be illegal, age discrimination isn't irrational. Older developers are generally more expensive. They generally can't or won't do 90 hour work weeks. And even people in very good health will generally have more issues the older they get.
As a conventional, salaried programming employee? Yes. (In what other field does 5 of so years of experience allow you a title with "Senior" in it?)
My experience is illuminating in that I'm blessed with genes that allow me to look much younger than I am. I'm now 50 and in casual encounters (e.g. in stores or restaurants) I'm still routinely mistaken for an 20s something possible student (of course I dress the part).
In the '90s, as I made the journey from 30 to 40 I noticed it became harder and harder to get results from sending out resumes ... until I got a clue and scrubbed my resume of the hard evidence of how old I was (education dates; by the time this happened I'd already scrubbed it of jobs prior to 1990).
The difference was like night and day, and if I watched my words I was able to keep up the subterfuge until I was hired and had to prove to HR I could be legally employed, something that didn't necessarily make its way to my managers. There was one interview a bit less than a decade ago where I slipped and mentioned working on PDP-11s ... the response was "Just how old are you?!??!!" (yes, that's illegal, but it was an instant honest response). They did hire me but it didn't work out; they were desperate but it's just as likely it was due to total cluelessness of the real customer, a state agency.
So my advice is one or more of the following:
Hide your age if you can and for however long you can. They can't legally ask.
Transition as quick as you can to a field that doesn't care so much about age. Embedded tends to be one (although not the Detroit car companies).
Get out of the conventional salaried programming career ("Nobody ever got rich typing"). As noted by others, you can move to management (which is genuinely challenging). You can be a consultant, although that tends to be a hard life. Or otherwise become your own boss, i.e. be a founder of startups.
Note that my experience is on the East Coast; I've heard that age discrimination in the Bay area is much worse.