The best thing to do is to be prepare to switch your career at some point. The tech industry is notoriously ageist so don't expect to retire working in the same type of job you have now.
I am 51. I got my first job in BigTech at 46. When I got Amazoned in 2023, within the first two weeks I had three offers. I was out looking again in 2024, I responded to a recruiter and had a job offer within two weeks. I am still an IC and half my job as a staff consultant is pushing out code onto AWS, the other half is leading projects, supporting sales, talking to customers.
There's a survivor bias, you see the older techs that are employed and people think "oh, there's no problem." But people don't take into account all the other techs that could not continue their career because they could not get a job as they got older.