Can we move this logic in to `closeUnopenedTag` itself?