Why Laptops sometimes not shutting down when Lid closed? Red-hot laptop from bag, why?
The solution to your problem is to configure your OS to sleep/hibernate when the lid-switch is triggered. There is no OS-independent, hardware-based solution for your problem.
I had an older laptop that would heat up in my bag (It was an old HP). Sometimes the little latch wouldn't trigger the hibernate mode (I think the little piece of plastic was broken).
Unfortunately, I don't know of any non-OS way of hibernating a laptop. If you're looking for a completely OS independent solution, then shutting down is my answer.
If you're willing to compromise a little on that restriction and you've already tried configuring your OS to hibernate when the lid is closed, and it isn't hibernating, check to make sure the laptop registers a 'closed lid'. Just watch the lights on the laptop, or try to manually trigger it with a small screwdriver (it's usually a little button near the base of the screen). If it doesn't, you could just try to hibernate manually before closing the lid. If the button works, and closing the lid is recognized by the OS, then I'd check to make sure you're hibernating and not just turning the screen off.
If your computer is hibernating and still heating up, then I'd say it isn't actually hibernating properly, or there's some deeper problem. If that's the case, customer support for your laptop may have an existing solution, or you may have to resort to simply shutting down your laptop.
Hope that helps!