I'm in my 20s and think about this a lot although I already moved to management (with a lot of software development, still) as well.
There's a great article [1] analyzing this problem (quotes from the article: "Professionals with higher cognitive ability drop out of STEM careers earlier and faster", "High-ability workers are faster learners, in all jobs. However, the relative return to ability is higher in careers that change less, because learning gains accumulate").
Knowledge depreciates a lot faster in software development than many other fields. That's why I really think about going into finance or sales (still fast-paced), but attending expensive top business schools and starting as an analyst with a low salary again is pretty rough after already building my current skillset. Currently feel a bit stuck with my career options right now. Money's still good and the work is fun, but working in a field that is set up to be a grinding mill as an IC is not an entertaining thought. High-tech projects will still be fun, I guess, but still definitely something to consider. Specializing early on may mitigate this.