Any chance you're doing something like
not declaring variables, and so you're loading something into the global space? In that way if you don't close AE, run the script via File > Script and then Window > [Script.jsx], you'll already have initialized certain things.
Best bet would be to post / share the full script so somebody else can check it out!
Running this, based on your code above, yields the same working result regardless of whether it's run from File > Script or Window > Script.jsx
(function () {
 var comp = app.project.activeItem;
 var layer = comp.selectedLayers[0];
 layer.property("ADBE Effect Parade").addProperty("ADBE Color Control");
 var colourControl = layer.property("ADBE Effect Parade").property("ADBE Color Control").property("ADBE Color Control-0001");
 colourControl.expression="var x = thisLayer.width / 2;\nvar y = thisLayer.height / 2;\nsampleImage([x,y], radius = [2, 2], postEffect = true, t = time);";
 var rgbValue = colourControl.value;
 alert(rgbValue);
})();