If you have a UPROPERTY to a uobject (class, actor, component, widget etc etc) which is not soft, then you are keeping it from being garbage collected. In unreal hard pointers to UObject are automatically nulled when an object is destroyed. It should all be handled magically by the GC.
Memory Management & Garbage Collection in Unreal Engine 5 | Mikelis' Game Blog
Garbage Collection & Dynamic Memory Allocation - Old UE4 Wiki