Adding a script with script_raised_destroy also solves the issue:
script.on_event(defines.events.script_raised_destroy, function(event)
unregisterModEntity(event.entity) end, {
{filter = "name", name = "tree-planter"},
{filter = "name", name = "air-purifier", mode = "or"},
{filter = "name", name = "wind-turbine", mode = "or"}
}
)
It registers the event of an entity being destroyed through a script (for example by another mod), so said entity can be removed from the global table like it should. It is always a good idea to include this event when checking for removed entities.