Fix race condition where schedule is already canclled while waiting for thread sync