Hey,
I also have this problem, though mine seems a bit more drastic. When it happens, it never turns back on by itself so can't be the case pressing the power button too hard, forcing a reboot. My case is a gel type any one, and it feels quite loose from the buttons. I have a stock phone/Android. And am on the O2 network in the UK.
I upgraded to the Nexus 6 in May this year. For the first 2 months it's been absolutely fine, but recently the battery is absolutely terrible. Notice how I didn't say battery life.
It came with Lollipop 5.1, but I upgraded to 5.1.1 when I got offered it on the phone.
Basically, what happens is, completely randomly, my phone will just shut off as if the battery has been pulled. I don't get the Powering Off warning appear. It just dies. It happened this morning and when it came back on, it had 92% battery life. Sometimes it happens during a phone call, other times it's when it's just sat there doing nothing in standby.
Other times, I will get the Powering Off warning appear, but this happens when there is still plenty of charge (it happened yesterday with something like 84% battery life) - it drops to 0% in seconds.
I've even had it happen while the phone is booting up. Everytime this happens, when I plug it and turn it on, I get the 'Android is starting... Optimising App x of x' process, which take 10 or so minutes.
Most of the time, if I try and turn in straight back on, I'll get the battery flat indicator on screen. If I wait 5 or 10 minutes it will then come back on, with battery showing where it left off. Rarely, it will come straight back on.
I have tried:
A standard factory reset (from Settings), multiple times
A bootloader factory reset
A bootloader cache wipe
A battery reset (as advised by Motorola - instructions below)
I never to a restore after a factory reset - always do as a new device. I've had this problem in factory state, so no 3rd party apps.
Battery reset:
With the phone ON and unplugged from wall charger, press POWER for 20 seconds until the phone force restarts. When the phone has restarted, connect the wall charger. Charge the phone to 100% and leave it connected to charge for a couple of hours after it has reached 100%.
Funnily enough, since doing this battery reset procedure, I think the problem has become worse. When it started it tended to do it with lower battery (40-50%, so still not low battery). And as above, it's started doing it with really high battery left.
One thing I haven't tried yet is a new, fresh install of 5.1.1 which has supposedly fixed problems similar to mine (the Optimising app x of x at bootup) - is this something worth doing or just get it replaced?
Thanks