Closed the connections before the tasks too