make lifecycle hooks work when using Stash, see #3199

The original fix for 2.2+ is not BC, hence this only does the minimal
thing (i.e. it does not make Stash or FSM well-behaved).