From my experience I want to say that it turned OFF because the battery discharged, this happened to me a couple of times, but after charging phone with either the lighting cable or a battery-case I noticed it still worked. Now, the advice to you (if you ever do it again and you have no way to turn OFF the iphone) or to someone else who cannot turn OFF the iPhone 5 before opening it or changing the screen is that: You do it REALLY careful, and you do the process of opening it the proper way (no more than 90degrees) then take out the little lid covered by the three(3) screws which covers the cables from the screen. After you are done with this, then you should move to the battery connector on the lower part, take out the two(2) bottom screws, then disconnect the battery from the logic board. Then you know that the phone is OFF, and don't forget to connect the battery and place all the lids with their proper screws after you are done working on it and before you close it. For more help click on this Youtube...
If you dropped your phone or if you or someone else replaced the screen or something dealing with opening the phone, then the screen might be messed up (LCD & touch screen). Replacing the screen should be a final solution after trying the other solutions mentioned above by others.
I had this problem too and this way helped me, good luck! Open up a stock app, like the Clock. Hold down the sleep button until "Slide to power off" appears. When it does, let go of the sleep button and hold down the home button. After about 5-10 seconds, the app will close. PS: It didn't really worked the first times so I kinda gave up, (this was at night). Then in the morning when I usually check my phone, it did worked. So try this first step a couple of times and let it sit for about 10 hours, then try it, if it really does not work, try again the same process, and if it does not work after, then follow these other steps by clicking on the link... http://www.cnet.com/how-to/four-ways-to-fix-an-unresponsive-iphone-home-button/