resolve cyclic object when closing database, also json stringify the list