Fixed db.close now it does not overflow