Given you are seeing the issue become intermittent / temporarily resolve with fiddling with the lid, this leads me to think the issue is a connector that isn't making perfect electrical contact. Generally with this situation, a good thing to try is disconnecting that connector, cleaning the metal contacts (all you need to use is a paper towel or Q-tip with a bit of rubbing alcohol), dry the connector (alcohol will evaporate pretty fast) and then re-insert and secure the connector.
Here is a video covering disassembly (and keyboard ''replacement'') of the model laptop you have. Note: many steps shown you WILL NOT NEED TO DO since you don't need to replace the keyboard (yet - you might if cleaning the connector doesn't work).
Video: https://www.youtube.com/watch?v=aKccaz2U_aA
All you need to do is disassemble to the point where you can access that center ribbon cable, disconnect / clean / dry / re-insert it. Then use the laptop for a while and see if the problem happens again. If it doesn't for a week or so, you're probably good. I say probably because intermittent issues are inherently a pain in the arse.
Good luck!