How to delete an asset from Editor in C++?

Took me some time to figure it out, but i think you can not instantly destroy/ delete Assets (or any subclass of UObject). Instead you can mark it as “pending kill” and the garbage collector will pick it up eventually. I did it by simply calling this function:

object->MarkPendingKill();

Additional hint:

forcing the garbage collector to do its work by calling ForceGarbageCollection(true) apparently is not a good idea, as it caused the editor to crash, due to some assets being a “nullptr”.