Let me briefly explain the principles. There're quite simple:
Everything you create in SceneEdit (layers, entities, regions...) is managed by Scene. When you change scene, the old scene is destroyed and the new one is loaded. All automatic. You can add new stuff to scene in scripts, using
Scene.LoadEntity(),
Scene.LoadActor(),
Scene.CreateEntity() etc. Objects created that way become part of the scene and they are managed by scene as well.
However, you can also create "global" objects, owned by the Game, using script methods like
Game.LoadEntity(),
Game.LoadWindow() etc. Objects created this way are never released automatically and YOU are responsible for destroying them when you no longer need them. Using Game.UnloadObject().
Now, to be able to destroy them, you need a reference to these objects. You cannot destroy them using their filename (it's logical, when you think of it, you can have ten objects created by loading the same file).
So, you'll need to store the reference when you are creating the object.
var SomeEntity = Game.LoadEntity("some\path.entity");
The "SomeEntity" variable now contains the
reference to the newly created entity, and you can pass the reference to UnloadObject later.
Game.UnloadObject(SomeEntity);
If you need to share the same reference between multiple scripts (like, one scripts creates the object, but other script destroys it), you will need to use global variable. A global variable can be accessed by any script, you just need to
declare it before using it.
// this line says: "I'll be using a global variable called SomeVariable, allow me access to it"
global SomeVariable;
// now I can read and write to the global variable
// if other scripts declare it using "global SomeVariable;",
// they will get access to the same variable
So the above script loaded an entity into a global variable. If other script needed to access the entity, or, say, destroy it, it would contain:
// get me the global variable, no matter who created it
global SomeVariable;
// and destroy its contents