I wouldn't worry too much . . . just keep it in mind . . . the future is filled with all sorts of unknowns . . . not 100% of developers will get laid off/replaced by cheaper labor but it's a possibility (Disney, CA Power company, in the news recently).
I'd recommend exploring having your own product/app/business if that interests you vs. depending on a company long term.
But lots of changes are going to come about in the next 10 to 15 year. Automation . . . interstate trucking, uber cars, garbage trucks, restaurants, this will eliminate a lot of jobs and businesses that provide services (truck stops, etc). So being a developer your job is more secure than a lot of careers that are going to be going through major changes.
Don't fear, worry about change, just be prepared/ready.
If you're talented I expect you can be a contract developer for as long as you want. But explore other options/opportunities.
There are developer jobs out there for 40+ year-olds. I worked with a developer who was 70+ for a little over a year. What some people do is they move to tech management positions such as CTO, programming manager, or work as software architects. That really depends on what you enjoy doing thou.
All except these:
> laying off employees in their 40s
> hire lower cost
which raises the question: what should a 34 year old developer be planning to do by time he is in his 40s? I'm realizing now that this might be the crux of my situation.