fix race condition in mutex release