closing the connection to the database at the end