implement setInterval logic to handle async db.close()