Disassembled the phone, and took off the power button from the main board. Turned out the soldering job inside the power button was badly done, and the looping was due to a piece of solder that had come loose and was shorting the connection.
So now I have a totally functional nexus 5, but to use the power button I have to stick a piece of tin foil down inside where the power button used to be. I have a mod on there that added a 4th home row button which covers all but the 'on' functions of that button.
May be easier than finding tin foil (or aluminum foil).
Barely 1.5 years after being purchased new. Combined with the fact that the battery on it was already shoddy and only degraded significantly with time, I legitimately would have to keep my charger always on me, or I might get stuck with a dead phone.
2 of my friends who bought Nexus 6P around the same time also had issues, with one hitting the infamous bootloop issue, and another one experiencing battery issues and automatic shutdown similar to mine.