fixed mutex issue in doeventclose