Close connection streams, reduce code duplication.