Fix finalizer for Database.