Here's [1] a data analysis looking into the phenomenon:
"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"
[1]: https://whoisnnamdi.com/never-enough-developers/