fix the following issue. root cause is that options.element is being reused when cleaning up, but if its value comes from a ref, it might be null at that point. 