don't downcast from std:.size_t to unsigned
fix leak on shutdown