I'm 46, I programmed a computer for the first time when I was 10, back when Pong was starting to wane and the Atari 2600 was starting to get big. I've been programming continuously since then for 36 years. It's been challenging me to stay with it that long, and most people I've known have dropped out for these reasons:

1.) Developers get comfortable with a given technology, and eventually stop learning. And the longer this goes on, the more exceedingly difficult it is to leave that comfort zone, because it makes you feel dumb and slow. When I first got into the industry, there were lots of folks doing things like IBM mainframe assembly and RPG/3 and COBOL. They'd tell me that that was where the real money was, and there was no need to learn new skills. After all, those systems weren't going anywhere, and they were bringing in fat checks. In fact, the more obscure the technology, the more money they make.

This particular trap of sticking with a technology is an insidious one that I almost fell into myself. In my early 30's, after working at the same place for about 10 years, I started coming to the conclusion that I was the best developer that I knew. I could do stuff in a weekend that other teams of people would fumble over for months. I was unstoppable. Then I changed jobs a couple times, and started doing game development, and started getting worried that I was actually not nearly as smart as I thought, and that I was losing my edge. But the real truth is simply that when you do the same kinds of jobs with the same technologies for many years, you get real good at doing those things. You find a comfort zone. And leaving that comfort zone feels wrong, stupid, and even counter-productive.

2.) It becomes tempting to switch to management. Over my career I've worked for innumerable managers who used to be developers in whatever technology was used 5 or 10 years ago, but now they do management. Often, they don't even realize how out of date their grasp on technology is. It's easy to fall into the trap of moving into management, because it's typically the only path to any kind of career development or upward mobility. I've gone into management myself for a few years, but then realized that if I want to be a good developer as my top priority, then I need to spend my time focusing on being the best at that, which can mean making some sacrifices. Once you move into management, you're done unless you keep your skills current.

3.) Developers need to continuously retrain themselves. This one kills most developers dead. You have to train yourself. The means not expecting your employer to do it for you or pay you to do it. Every 5-7 years over the last few decades I've totally changed my technology platform many times, and every time it was because I had spent the last year or so getting ready. I'm talking about spending a significant amount of time working with and understanding technologies other than the one you're using right now, say about 200 hours per year at least. I haven't read the responses on this forum yet, but I guarantee you will see a pattern of developers feeling like they don't need to work hard to retrain themselves. Saying things like, "programming is my job, it doesn't have to be my hobby as well." This is a fine attitude, as long as you aren't planning to be a developer for more than 5-10 years.

If you're in software development for the long haul, more than 5-10 years, then you have to be continuously training. If you're not absolutely serious about staying on top of new technology, then your skills will be obsolete and niche within 5-10 years.