Fix a synchronization issue between the main thread and the background threads.

(WindowImp::BackgroundTask::operator(), WindowImp::poll) : Refine
(WindowImp::BackgroundTask::isRestarting) : New