This works great.
In my case deleting the widget from memory was necessary, because I store different types of widgets in the same variable dynamically. Not deleting it from the memory (specifically calling the CreateWidget<T>() function) caused the engine to crash.