Rest a lollipop stick on the power button before the lid closes, works
If that doesn't work, try this one.
Go in control panel>performance and maintenance>power
options>advanced. There is an option: " When I close lid of laptop..."
Select "DO NOTHING." That solves the problem.