closing connection with db in stream