The chemical you're talking about is DMS.
It's released by malt at temps above 140 (don't trust that #, my memory is shaky). At boiling temps it's released in the steam, so you need the lid off. After boiling the DMS is still being produced as long as the wort is hot, but if it's not boiling it's not escaping. You want to cool the wort as fast as possible to keep it from getting out of control.
Lid on or off during wort cooling shouldn't matter in this regard.