I doubt that's an issue with the OS. Your battery is probably dying. I have the same issue and am getting it replaced tomorrow. It's just not dependable anymore.
My battery started dying on my 4 a few years ago, it was pretty gradual. My battery on my 6 has been excellent for the year that I've had it and only this morning did it shut down on 20% suddenly.
I'll keep my eye on it.