I can't handle 40 hours of sedation every week for the rest of my life. I chose to work in the defense industry specifically because I thought it would afford me opportunities to work on exciting high-tech shit. That bubble's been burst for some time now.
So a bank or similar isn't what you need. Fine. The GP's point is still valid: it sounds like your problem isn't software development, it's your job. There are plenty of really enjoyable software jobs around, for whatever your definition of "enjoyable" is (assuming you actually like coding, and you probably do otherwise you wouldn't have liked it in the past). You just need to find one, which means you first need to figure out what kind of environment will fulfill your needs.
Personally, I'm in my mid-40s, still writing code, and I expect to be gainfully and happily writing code until I'm ready to retire. I've gotten progressively pickier about what kind of place I want to work, but that's okay. In my case, my primary criterion is the number of idiots I work with; as long as that is sufficiently low, I can find challenging and interesting problems in any industry and problem space.