I got a workaround with console commands to keep playing.
I noticed the crash happens when the empire that is getting destroyed is at war with more factions. When the peace or takeover of the last planet happens and some other faction from secondary war is also occupying starbases the game always crashes (observed this in 3 different games).
If we can declare the war on that other faction and secure all systems for ourselves before we destroy the AI empire the game won't crash.
If the crash happens randomly it's probably some other AI empires fighting eachother and then we need to go to console, type: observe - to go to observer mode and look where is there and empire that's about to get destroyed, then switch to one of the factions that are destroying it by typing: play x - where x is a number from 0 up to the number of empires in galaxy (0 is the player), and then switch occupation of starbases by clicking on it and typing: own.
So basically when an empire is dying it can't be at more than 1 war at a time. Otherwise the game will crash if two different sides occupy its sectors. One of the sides need to make sure nobody is occuping any sectors of a targeted empire.