Is it safe to work with MacBook Pro lid closed?
Yes - they are designed to work when closed. The machine will shut itself off if it ever exceeds the safe operating temperature (unless of course there are multiple failures in the sensors).

You can measure the battery temp - and may reduce the useful life of the battery if the temperature is always higher (and substantially higher on the order of 10 to 30 degrees F) for extended always on periods.

You may never need a new battery with the new 5 year / 1000 cycle batteries - so that might not even be a concern. I'm happy to spend the $99 on a new one if I really need one after the normal 3 year coverage has lapsed with Apple Care. Other than the battery - the rest of the electronics is basically immune to heat. The next thing to go might be a blower bearing - but those are far cheaper to have replaced than even a battery.