Set ready exiting from the scope early

so that the main thread won't deadlock on self.ready if bad things happen.
Merge pull request #614 from rainwoodman/patch-3

Set ready exiting from the scope early