Yeah -- the original commit that introduced the XML writer used a context manager, until I remembered we were still supporting Python 2.5 at the time.  Now that we're not, I agree all of backend_svg should be refactored in that style, but not for this PR.