On some models, if you root them, you can cap charging to reduce the chances of that happening.
https://f-droid.org/en/packages/mattecarra.accapp/