close connections code put in finally block