html: fix inserting missing close tags when a close html tag is encountered