clean up and fix db.close error with sig