I had been happily using a Nexus 5 for the past year until I did an OTA upgrade to Lollipop, after which it began crashing (powering off) multiple times per day without apparent pattern (sometimes during GPS navigation, during phone calls, while taking a picture, etc.) In addition to requiring a reboot, these crashes sucked down battery. I did a fresh factory install of Kitkat, which I expected to fix the problems, but they continued, even in safe mode. Is there anything else to try, or is it time to buy a new phone?
Update: After posting, I installed the latest version of CyanogenMod, and my phone only crashed once, right after enabling location services for Twitter. Besides that, it worked fine, although it was not heavily used (on vacation) and battery life was poor (lasting only an hour or two). After getting back from vacation, I did the full wipe and factory install of Lollipop 5.0.1 suggested in comments. The phone crashed twice (sucking down battery) during the subsequent setup, although I made it through on the third try.