There should be an explicit close() to the db, we should not rely on \_\_del\_\_ for this kind of thing. For more information ping kali, he digged into an issue similar to this one.