Fix scheduler shutdown See merge request !3517 (cherry picked from commit 9f14dc93) ac72ea95 Fix scheduler shutdown