I'd start with LTN, Train Supply Manager and Electric Trains. All three of those mods create extra entities when their particular item is placed in the world and remove it when it is mined/destroyed.
Looking at your clear lab code it gets all entities on the lab surface then goes down the list destroying them indiscriminately. Which is fine until a player places a multi-entity item. Player places say LTN train stop, LTN detects LTN train stop and spawns a special LTN combinator next to the train stop. Your mod when cleaning the lab destroys the LTN train stop, LTN destroys LTN combinator, your mod attempts to destroy LTN combinator, your mod blows up because entity isn't valid.
I bet adding a quick sanity check to the start of DestroyEntity function would solve the issue for just about every mod.
if not entity.valid then
--Entity already destroyed. Next!
return
end