When it comes to jobs mysteriously drying up: you're talking about ageism. Thanks to covid-19 almost every offer I currently have on the table is remote, and I have 6 years of remote experience under my belt already... I predict that ageism will start to fade along with traditional office work. At the very least I can fudge my resume and make it look like I am younger with less experience if absolutely necessary.
Furthermore I have known many over 60 programmers who have no issue getting a job. Ageism might be an issue in silicone valley and might prohibit one from getting a gig at a new start up, but I believe this problem is overblown. I think that some older devs just fail to keep up with the industry, lose their passion and blame their personal failures on ageism.
My comment is about the perception of older programmers and why this may affect enrollment in Computer Science.
I agree with your analysis, but this is not the perception that the general population holds.
That's not to say that it isn't possible to survive past 40 as a programmer, my point was just that this is a deterrence for getting a Computer Science degree. Think about any other profession; doctor, lawyer, engineer; the perception of these professions is that they get better with age. Computer Science is totally opposite, it's a field dominated by young hotshots who spun the wheel'o'algorithms and got lucky.