Close connection on finalization