GeveraP wrote:
The battery is at 58%. But this has been a random decline from 80% 3 months ago.
It's no wonder your phone is shutting down. Your battery isn't just degraded, it is SEVERELY degraded. Apple recommends a battery replacement when the health dips to 80%. At 58%, not only are you going to have issues running your iPhone, but your battery may swell and destroy the phone completely. You simply don't have any choice other than to pay Apple about $100 to replace the battery NOW or trade the phone in on a new iPhone.
You can schedule a battery replacement here if you just want to do that --> iPhone Battery Replacement - Apple Support
Personally, I wouldn't plug your iPhone in to charge while you sleep and I would completely power it down when not in use or within your view until you either replace the phone or get the battery replaced. Only charge a phone with such a degraded battery within your sight while you are nearby. And if I'm scaring you - GOOD. This can be more serious than you imagine.