Switch scheduler shutdown to work with flags