make sure we close the connection in any case