Attempt to deflake logging tests

Deferring closing the connection until after the test is done
seems to be the right thing to do.