check return value of sqlite3_close(), retry up to three times.
diff --git a/openbsc/src/utils/meas_db.c b/openbsc/src/utils/meas_db.c
index 2e70b31..cf4ce6e 100644
--- a/openbsc/src/utils/meas_db.c
+++ b/openbsc/src/utils/meas_db.c
@@ -314,10 +314,20 @@
 
 void meas_db_close(struct meas_db_state *st)
 {
+	int retries;
 	sqlite3_finalize(st->stmt_ins_mr);
 	sqlite3_finalize(st->stmt_ins_ud);
 	sqlite3_finalize(st->stmt_upd_mr);
-	sqlite3_close(st->db);
+	retries = 0;
+	while (1) {
+		if (sqlite3_close(st->db) == SQLITE_OK)
+			break;
+		if ((++retries) >= 3) {
+			fprintf(stderr, "Unable to close DB\n");
+			break;
+		}
+		sleep(1);
+	}
 
 	talloc_free(st);