Ok, I think I know now what you mean by sandbox (found it in the scenarios). This puts you into God mode, which in turn breaks a few things regarding inventory. I think, based on what evildogbot100 had written originally on the main page, at one point in time you could pull the fuel out without a crash. I don't know if there's been a change in Factorio or maybe I accidentally removed a key line to prevent the crash, but obviously that appears to be what's happening here.
I'll look into it and see what I can do, but for now please note that being able to remove the fuel while in God mode may not be preventable. As such, I strongly recommend against mining the locomotive while loaded with fuel or manually removing the fuel while in God mode. Use pumps to drain the locomotive that way.
EDIT: Bah, ok, it's regardless of the fuel, ie any kind of inventory interaction. Dang. I'll have to put something in to bypass this for now.