improved previous commit

The std::function’s need to be cleared as the very last thing, in case
the handle is deleted within the callback.