I've had my Nexus 5 since it came out in 2013. Earlier this year I started having an issue in which the phone would just randomly shut off. I would power it back on and it would still have a lot of charge left.
At first, it was sporadic, but then it was gradually doing it more and more...