Nexus 5 crashes, battery down to 0% on Android 5.1.1
This issue is widely reported and discussed on Google support forums. I experienced exactly the same thing on my Nexus 5 when running any CPU/GPU intensive apps. In my case running SkyForce game immediately caused the phone to shut down with 100% repeatability. Most of the time after the restart the phone would report significantly reduced battery charge level. Repeating the attempts to run SkyForce resulted in further shutdowns with battery charge quickly dropping to 0%. In some cases the phone refused to turn on after the shutdown unless connected to an external power source.

I attributed this behavior to the battery's inability to sustain the load, i.e old battery. Under small loads the battery behaves as if everything is normal and maintains the voltage. Under elevated loads the battery suddenly gives in and the voltage crashes "through the floor". This is expected behavior for an "expired" LiIon/LiPoly battery. It easily fools battery management subsystem into believing that the battery is at 100% charge, when even a slightly elevated load causes the voltage to "crash".

I bought a new battery and did the replacement, which fixed the issue for good. I have been using my Nexus 5 for a few months now with no anomalies of any kind.

The only thing that is not immediately explainable is why most people report the issue only after the system update. BTW, in my case the problems began after update to 5.1, not 5.1.1. I received the update to 5.1.1 later, after battery replacement, and it was completely uneventful. Yet many people report that in their case it was specifically 5.1.1 that triggered the problem. The only explanation I have is that the updates change something in battery management algorithm that tends to exaggerate old-battery issues.