closes connection on finish