Wakeup more carefully with the endch.

With the new endch approach, there were new bugs around code paths
around waking up from sleep.

cbugg: closes bug-376

The entire sleep/wakeup/purge codepath might get refactored away due
to the new fileService, but until then, this should help.
More room to workaround sleep races in tests.