Correctly escape closing tags in embedded scripts