Sounds like a fault somewhere in the wiring (or a "switch" that is located inside the hinges for the laptop screen. Not 100% sure but without knowing make and model of your laptop, it is my best guess.
What you can do is the following:
- Select "Power Options" in the "Control Panel" list.
- Click the plus sign next to "Power buttons and lid" to expand its sub-list.
- Click the plus sign next to "Lid close action" to expand its sub-list.
- Click the word "Sleep" to open a drop-down menu next to the power plan you wish to adjust (e.g. Plugged In). Select "Do Nothing" from the drop-down menu.
- Click "OK" to save your settings and exit the window.
This should disable the sleep option, then you wont have to worry about it until you can get it fixed properly.