fixes infinite loop in mutex dtor
Added test case to prove this bug