ensureDeinitialized() {
        if (this.lifetimeId !== undefined) {
            let val = this.mortalValue;
            this.lifetimeId = undefined;
            this.mortalValue = undefined;
            this.deinitializer(val);
        }
    }
Cleans up the stored mortal value, if necessary.