I myself am 40 and am gainfully employed and paid well in a top SF tech company, I have several mid to late 40s friends who are highly paid and appreciated at their jobs and have turned down offers from FAANG. I think the key is realizing what more jr engineers able to do well and compete at something else, like depth (or extreme breath) of knowledge, soft skills, organizational skills, and of course leadership.