finally close the connection