There is probably a small switch which is operated by the cover when it is closed. Have a look as maybe it has moved. If not it may be faulty and need replacing. Also a piece if insulation tape over the active part of the switch might get you printing in the meantime.
Surface Pro (2017) vs Surface Pro 4