It’s not a software glitch. With the peak performance capability disabled, the iPhone will be delivering peak power at all times. Under certain circumstances, for example opening an app with a high power requirement, the iPhone will temporarily request more power than the battery is able to supply. This causes the phone to switch off.
There is a good explanation of the new setting here:
https://www.imore.com/how-to-use-battery-health-ios
Prior to the update, iOS reduced its power requirement automatically in the background. The inability to switch this off caused an internet outcry.