Interrupting cleanup which contains emit

When killing process we should be able to determine whether we are inside `onComplete` and in such case wait with killing until we're outside.