cleanup entity scripts when changing domains or entity is deleted

QHash::remove(key) is resilient to the case when key is not in the map, so you should just call remove() and not bother with the contains() call and avoid a lookup.