Fixed race condition in Leave operation