Generally,as per software and in windows When we close laptop Lid then it takes you into suspend or sleep mode or power management saving mode and as per hardware there is not any hardware except sensor at the place of lock of lid or at a button on body . Only the hardware wise keyboard and screen gets touched. Nothing gets bad or dangerous for closing the lid.
The major benefit of closing lid is the screen get rest in place of keeping closed its better then keep it open and hanging and as power saving mode helps to keep the display or HDD or devices get rest.
But as you use the laptop, through monitor the major thing is that the power management stops power keeps HDD or SDD in sleep mode power of and it sense that your laptop is not being used and still its being used by external display your monitor LED secondly other external devices like USB or wifi or bluetooth also gets less power voltage or current or go to sleep mode due to Power management settings in BIOS or windows.
FIRSTLY over heating in laptops is due functionality of Power Chips or Power Recharging unit or power circuit for charging its general problem with mobiles and Laptop when we work on laptop with charging mode it battery and the Power chip of charging unit to gets heated as its giving more voltage current and power to battery to charge as at the same time battery is charging and being used by devices so its always a good practice to use Electronic devices like laptops tabs on direct power of inverter or UPS when its available and batteries should be used when you using it remotely or Electricity is not available for backup purpose.
SECONDLY over heating in laptop is due to CPU RAM HDD SSD and various other electronic components capacitors ICs transistors chips discharge heat for which heat sink and fans are there (only on Processor North South Bridge of motherboard have heatsink or cooling systems or in some models on RAM , but other electronic components dont have this heat sinks) in high end laptop or gaming laptop there are High end cooling system or vents or big more power cooling fans are provided and they are tested benchmark for cooling. But in economic models the heating they assume that these laptops will be used less for household or official use and so not much cooling fans vents or systems are provided.
As per my knowledge experience and my point of view advice suggestion
Remove batteries and use laptop in direct power of adapter current as your battery life will be more and battery will be used less and you can close the lid after removing battery and u should put the adapter plug on Inverter or UPS for using backup protecting laptop form electric surges and over voltage
You should alter change settings of power management and change the settings of power on closure of lid that is no power to HDD SSD or devices and increase the limit of hours for HDD and devices see links given below
As case of overheating you can use
( as you have not mentioned your laptop company and model if you provide i can find softwares and cooling system that suits your laptop)
a. software to monitor temperature of CPU graphic card GPU or RAM and create a table to compare and note down date wise temperature and see whats the difference when lid is opened and closed or using laptop screen or external monitor or led. I prefer software download from the laptop Manufactured company website find if they are providing or u can use 3rd party software's as suggested by other users . Watch which part is overheating more on closing lid for 2 -3 days regularly and do let me know we may troubleshoot it.
b. increase Internal Laptops FAN and CPU FAN or GPU FAN Fan Speed through software prefer software download from the Laptop Manufactured company website find if they are providing or motherboard or GPU graphic card manufacturing company
c. Search External laptop cooler FANs or laptop water cooling systems if any available for your model.
Hope above suggestions and advice help you do try to tell me your laptop company and model may be we can suggest or provide you with better troubleshooting or advice. If any of the suggestion advice helped or worked do tell me in comment for my knowledge and if not worked then feel free to ask further for doubts clarification in comments. if worked then dont forget to vote for answer or accepting the answer.