How to set the widget class to none in c++

What is LockedOnWidget? is it a referene to a UUserwiget then?
If so just call removefromparent on it and set the uproperty to nullptr.

Just add in checks to where you access the variable.