Looks fine to me. Its good that you detached and cloned, otherwise you would be keeping the graph or storage of the output alive.
In general having the hook registered on the module in itself won’t keep anything alive, if you were worried about that. Its what you do as a side effect in your hook, i.e., what you store that could be a problem, but that seems to be okay here.