Properly calculate sleep time in ProcessWaitUntil{Stopped,Exited}

Backport of Mikhail's fc5ae177.