The GUI was not opened.
I use a lot of mods, mainly KS2 and S2 + custom ones (I put the list bellow) so the root cause may be shared among others. Though if it can help you have a more defensive approch in your code :
11281.314 Error MainLoop.cpp:1285: Exception at tick 50213070: Le mod Factory Inspector (1.1.9) a engendré une erreur non récupérable.
Merci d'informer l'auteur de cette erreur.
Error while running event factory-inspector::on_tick (ID 0)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
[C]: in function 'index'
__factory-inspector/script/production-tracker.lua:35: in function 'updateProductionAndConsumptionStatsAM'
factory-inspector/script/event-handlers.lua:45: in function <factory-inspector/script/event-handlers.lua:15>
aai-industry
aai-signal-transmission
aai-signals
aai-vehicles-chaingunner
aai-vehicles-flame-tank
aai-vehicles-flame-tumbler
aai-vehicles-hauler
aai-vehicles-laser-tank
aai-vehicles-miner
aai-vehicles-warden
advanced-combinator
alien-biomes
alien-biomes-hr-terrain
ArmouredBiters
assemblyanalyst
attach-notes
Automatic_Train_Painter
baguette_super_generous
baguette_TD
CircuitHUD-V2
Cold_biters
combat-mechanics-overhaul
combinator-toggle
Command_and_Conquer_Low_Power_Alerts-016
Command_and_Conquer_RedAlert_Sounds
crafting_combinator
Deadlock-AAII-bridge
Deadlock-SE-bridge
DeadlockCrating
DeadlockLargerLamp
DeathNotice
DragonIndustries
EditorExtensions
ElectricTrain
emoji-signals
equipment-gantry
even-distribution
Explosive_biters
Factorissimo2
factory-inspector
factoryplanner
Flare Stack
flib
Flow Control
FluidMustFlow
FluidWagonColorMask
Geothermal
GUI_Unifyer
ImprovedCombinator
Infinizoom
informatron
Inventory Sensor
jetpack
Krastorio2
liborio
LogisticRequestManager
manual-inventory-sort
miniloader
Mining_Drones
missing-circuit
ModuleInserter
Moon_Logic
Not_Enough_Todo
No_Bot_Charging_Repair_Turret
PatchFR
pushbutton
RealisticFlashlight
RecipeBook
Repair_Turret
Robot256Lib
robot_attrition
RunSpeedToggle
rusty-locale
SchallEntityInspector
SchallPickupTower
shield-projector
Shortcuts-ick
shortwave_fix
simhelper
snouz-useful-icons
sonaxaton-resource-map-markers
space-exploration
space-exploration-graphics
space-exploration-graphics-2
space-exploration-graphics-3
space-exploration-graphics-4
space-exploration-graphics-5
space-exploration-postprocess
Squeak Through
stack-combinator
StatsGui
stdlib
Switch_Button-1_0
Teleporters
Total_Automization
Unit_Control
VehicleSnap
walls-block-spitters
WireShortcuts