Your "delete & NULL" subtitle should have been a hint :p
Yeah it's not an infinite loop, used that term as a shortcut.
The gate's destruction is likely the major culprit. Each sector has a sort of cache which, amongst other things, lists if there's a gate there without having to check the whole local object list whenever the information is required (very often). The cache also handles a few calculations to speed up path-finding (neighbors and weights, it's an A* pathfinder). It's deletion forces the cache to be updated, while it is not processor intensive by itself, there's likely a bunch of ships (handled by other threads) who have to recalculate their paths completely, and they may even fail at doing so until the cache is updated. Normally that wouldn't take more than a few 10s of milliseconds, but with the deletion of multiple docks on top of that (which basically forces all threads to halt during the deletion and resume work all at the same time when it's done) and depending where and what were doing the linked trading ships, I can see how it can takes a few seconds.
I'll have to double check the other ending that delete stuff, but i don't think it kills gates, so that shouldn't be as bad. I did test each ending, but on Galaxia, which is not that big, easy to path through, and it was in the mid game at best. So the lag was barely noticeable. I'll refine the process a bit when I get the time to do so.
About the asset list, it doesn't get refreshed if you're not on the relevant tab, but it gets loaded once when the menu opens. I will edit that accordingly (and ofc, hiding civilians and docked ships helps a lot when the empire gets very large).
Cheers,
Eska.