An @contextmanager will raise an exception from its yield statement if
an exception happens in the with-block that uses it. If the context
manager needs to do clean up, it should do it even if an exception is
raised, so it needs to be done in a finally clause.