ensure closing the connection