fix bugs in unloading scripts when changing domains
Merge pull request #3855 from ZappoMan/sitEntityScript

fix bugs in unloading scripts when changing domains