Have you tried a hard reset?
Press the two buttons on the back of the camera with a green dot by them. For the 5100 they should be "Menu" and "Information".
My D5300 does this sometimes but I know what causes it - I have a portrait battery grip and when the tripod is hooked up, if I pick it up by the camera (and not by the tripod), the weight of the tripod pulls the grip downwards and interrupts the battery connection, so the camera has shut off without powering down. This may be irrelevant to your problem but it's worth knowing.
It could just be that you shutter has reached its end of life. You can check the life expectancy of the D5100 shutter [http://www.olegkikin.com/shutterlife/nikon_d5100.htm|here]