This is true in any field: your employment picture looks very different at 40 than it does at 20. Lots of the reasons why are more due to real-life (TM) than the job market. At 20, you don't really mind renting a spare bedroom in the basement of somebody's house and working 100+ weeks trying to build the latest whatever non-world transforming consumer web thing. You
have all the time in the world and no obligations beyond growing your career. You're living to work at this point.
At 40+ you probably have a couple kids, a mortgage, a spouse, education loans, car payments, family vacations, pets, children's activities, children's pets, your own personal activities, cocktail parties, maybe saving up for your kids' college educations, whatever. Unless you've found yourself without these kinds of obligations, your job will end up being defined as something that can fit a work to live scenario. This is very hard to do in the previously described scenario.
So what's left? Some startups will let you do the 9-5/5 40 hour work week, but the reality is that big boring mega corps, building boring B2B insurance/inventory/timecard processing/bleh software is where you're likely to find the kinds of jobs that fit your new "adult" lifestyle. And you know what? You won't really care all that much.
If you do care, and you're tired of figuring out the access permissions for this role as part of that use-case for the umpteenth million time, you can career shift into management and start learning about the business you were supporting as a developer. You might want to end up managing other developers, being a "nerd herder", which presents an whole new set of fantastically non-deterministic challenges. You might move into product or program management, and be responsible for overseeing execution of contracts or high-level delivery of vague CEO initiatives, an entirely different challenge.
You may even want to take the plunge and shift into sales, starting as a sales engineer, but developing your own clients and moving into a full-service sales and solutions provider role...which you might later turn into a business consulting company later. Your hours might be more flexible and your pay can be unlimited in this kind of role.
Lots of startups make a big deal about the "full-stack" developer, you can do front and back-end systems with equal finesse. But a "full-business" developer, who understands the entire business from sales-cycle to post-delivery product-support can be extraordinarily powerful and I guarantee that job can be very interesting. The tech can be boring, but the kind of critical thinking and task breakdown skills you might bring with you from development can be really useful elsewhere in the business world.
You might even learn enough about some segment of the "business stack" that you realize you can launch your own startup targeting software to solve some problem you saw when you were operating in that portion of the business.