Why does my Nexus 5 go into stand-by randomly?

A

AC Question

I have my Nexus 5 since a few years now and since about two weeks ago I have this issue. Sometimes my phone turns itself off by itself without me pressing the power button. When I try to turn it on again it shows the lockscreen and after entering my code it often shuts down again right away. I really don't know why this keeps happening though it could be because I recently got a new phone case specifically for a Nexus 5 which has the function of making my phone shut down when you close the case and turn on when you open it. Could that somehow be the reason?