diff --git a/src/scitokens_cache.cpp b/src/scitokens_cache.cpp
index 0538dc5..dd4e5c7 100644
--- a/src/scitokens_cache.cpp
+++ b/src/scitokens_cache.cpp
@@ -250,5 +250,7 @@ scitokens::Validator::store_public_keys(const std::string &issuer, const picojso
 
     sqlite3_exec(db, "COMMIT", 0, 0 , 0);
 
+    sqlite3_finalize(stmt);
+    sqlite3_close(db);
     return true;
 }