Since your scriptings still execute after you have locked your form, you running into the described scenario. To avoid that you'll have to put your scripts into an if expression, so they do execute only under specific circumstances.
Sample 1: Use the value of a (hidden) reference field
// Only execute script when value of reference field is "0"
if (myReferenceField eg "0") then
$ = Sum(Price1, Price2, Price3, Price4, Price5, Price6)
endif
Sample 2: Use a fields property
// Only execute script if this field is not locked
if ($.access eq "open") then
$ = Sum(Price1, Price2, Price3, Price4, Price5, Price6)
endif