Update version and close database properly