Close connection before restart.