how to check end of the game

Not sure, but you can try to use virtual Destructor of SWidget (SCompoundWidget is not overriding it)

virtual ~SWidget();