
What's after 40?
What have you seen most people do after 40 in IT ( who from starting worked in good us based MNCs) in case they are fired??
There are many roles for people in their 40s in IT industry. If fired from one company, you interview and join a different company.
Staff Engineer, Principal Engineer, Solutions Architect, Enterprise Architect, Engineering Manager, Program Manager, etc. kind of roles available for 40+ year old software professionals.
And for 50+ people, roles like Principal Engineer, Principal Architect, Senior Program Manager, General Manager, Director, Associate VP, VP, C-suite roles, etc. types of roles are available.
Apart from these above, you can always continue to work as a developer in contractor / freelancer positions, at any age.
Retire

Appreciate this question
Good thought!
I think people might move to their hometowns and retire