Close repository after each operation

This prevents the tests failing when they try to delete the
.git files, but there is still a file lock (in Snake YAML),
so does not yet fix gh-45.