Fix HTML error: close a tag only if opened.