Prevent infinite loop triggered by `sitemap_close()`, fixes #600, props @pbogdan