iPhone 5 shutting down automatically again and again My iPhone 5 (factory unlocked) of three years (almost) started shutting off by itself since yesterday. It is completely unusable. Most of the time now, as soon as I boot it up again and unlock it, it shuts off. Other times, it stays on for a while before I run any app (stock, third-party, settings) and it shuts off. On rare occasions if I keep it in airplane mode, it stays on. Until, it shuts down later. I suspected something related to network connectivity was triggering something that was causing the phone to turn itself off. I tested by removing the SIM card altogether, but I couldn't find any particular pattern. 

I have tested with the battery at > 50% and > 80%. If it is a software issue, I am assuming an iTunes restore to 9.2 should do (it's in the process). 

It's running iOS 9.2. No jail-breaks. No recent physical abuses inflicted on the phone to warrant a reaction like this. 

Can anybody please share any ideas on what might be the issue here? 

Update: If it is plugged directly to a power adapter, it does not shut off with or without network enabled.

Update: 9.2 restore didn't help. I also experimented by leaving the phone connected to the power adapter but with the adapter not connected to any power source. It didn't shut off all night. Since then, I have been using it without it being connected to anything. The battery has drained from 100% down to 70% so far, with network/wifi and everything enabled. It hasn't shut off. This is perplexing.
Since your phone is 3 years old and operates correctly when plugged in, it's time for battery replacement.  Doesn't matter that you think the battery is at 50 or 80 percent, the battery has aged and the indicator is no longer giving you accurate information a result.