Counter example: I lead a software team doing new product development for a multi billion company NOT in the valley. Plenty of my engineering coworkers are grandparents. They are very much comfortably employed.
My boss is 50ish, young at heart and a brilliant software architect. He still gets actively recruited and has no end of companies approaching him for contracting gigs outside of work.
Find a niche and stay effective. You'll probably be employable forever.