Not in a place I can test right now - but I do know sometimes timing issues can get you.
On my delete rotuine (not the same but close) I have serveral sleep lines to make sure the system is ready (even after a task is DONE, sometimes you need to wait a little).
I had to sleep after power off, as I was noticing I would get the waitfortask back, but the guid still showed running for a few more seconds.