MFC r268078 and r268080:
Fix for memory use after free() and mtx_destroy().