I was a software dev with 25 years of experience in lots of in-demand languages like C++, Python, JavaScript, CUDA, etc. In 2015, I was sitting at my desk, waiting for the daily standup, when the CEO tapped me on the shoulder. He said he wanted to speak with me in the conference room. I knew it wasn't good, because we had been burning through money like there was no tomorrow. When I entered the room, our usually jolly VP was silent, staring forward. Our president looked very somber. The HR lady was CRYING with a box of tissue in front of her. They laid it out for me. I had two choices: 1) take a two month severance, 2) take a job with the same pay and benefits with the parent company downstairs. Being an empty-nester with two kids out of the house, but a wife to take care of, I took the latter. It took me one week to figure out how much I hated being a "Performance Lead Engineer" and how much I hated the parent company.
I had already decided to dip my toe into the waters of cyber security by taking courses and going for my CISSP and maybe my CEH. On the first night of the "Cybersecurity Fundamentals" course at the local U, the instructor mentioned he had his own company. I asked if he was taking resumes. I got my first interview two days later, and I was hired three weeks later. Two and a half years later, I was the CTO, leading penetration testing of all sorts (including physical engagements) and being responsible for the pentesting architecture and processes.
Now, I'm a Red Team Lead at an insurance company, and I do side-gigs (with full knowledge and permission of the company). Being a software dev (with some QA and Linux/Windows admin experience) turned out to be a "secret weapon" in learning how to do pentesting.
The youngsters are amazed that I have over 20 certifications in pentesting / red-teaming, and I have no intention of slowing down. I'm having way more fun than I ever had doing coding... or rather, software dev. (I agree with a buddy that "coding is fun, but software dev usually sucks, because it is usually driven by those who don't understand it").
Leverage that experience to do what you want and what you enjoy.