Making sure connections are closed