This is incredibly peculiar. I copied your script to run for myself, and after a bunch of testing and getting more and more precise (stupidly precise) with finding what crashes, I think I've found the root cause.
The core issue is that this appears to be a bug related to tasks, how they are managed internally, and breaking inside of tasks. The most barebones, fundamental example I can give is the following:
#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["test"]
@Initialize{
A;
}
task A{
loop(2){
B;
}
}
task B{
yield;
break;
}
@MainLoop{
yield;
}
@Event{
alternative(GetEventType())
case(EV_REQUEST_LIFE){
SetScriptResult(1);
}
}
This script should just instantly crash. Important pieces are that there are multiple instances of B running that were called from inside a loop, B yields, and then B breaks.
If it returns it's fine, if you just write B;B; it's fine, if there's no yield or otherwise if you space the B calls for longer than B takes to run it's fine. Generally the more instances there are the easier it is to crash, and mashing ctrl also seems to help it along.
This relates back to the actual problem script, I promise, I just dug really deep to get it this compact. The script executes this sort of behavior by running multiple instances of AmuletShoot, which each wait for a bit, and then break if the boss has 0 life, which is why it happens once the boss is defeated. If you remove the life condition and simply break, the script will crash most of the time. The reason why it seemed sporadic probably comes down to when each task started and when the boss died.
To be clear, if you replace your breaks here with returns, that should fix the problem.