To reproduce, just take OptimizeWeekly.MyD and add WhenFinished(Exit) underneath Description(). Run MyDefrag by executing the script directly using -d 2 as your arguments. This worked perfectly fine up until version 4.2.7.
Using C: -d 2
as arguments and your modification the OptimizeWeekly.MyD script exited like it should.
Have you checked the MyDefrag.debuglog
so that you are running the right script?