I can take care of this this tonight or this week-end. It just occurred to me, though, that my proposition of when to reset isn't good: I imagine that it would be natural to register shutdown handlers before wakeup, so my proposition would remove them before they are called. Instead, it would be simpler to reset after they are all called, ie. just before the source goes to sleep. (So @smimram, feel free to reset the list after the List.iter where handlers are called.)