Commit some staged changes
Defer closing connections to prevent leaking them