#1 You missed the unlockexection to your lockexecution.
#2 Needs a bit explanation:
Let's assume you have 3 tracks in queue and the next up is a requested (*) track.
Your script begins, waits for the requested track to reach the top of the queue and removes that track.
It then readds the track on top and then a Jingle on top of that. Your Queue now looks like this:
We've reached the end of your script and it begins at the top again because you set it to loop.
Now it waits for 1 track to play (your jingle should start) and then checks the top of the queue if that is a requested track. Obviously since the Jingle just played your top-most track is the request again and your script will add another jingle. Repeat this to infinity.
A proper fix would require you to wait for one more track only if you added a jingle. To do that you need to convert the if to a loop with only one iteration, though. I'm too tired to explain that now.
Alternatives: Only check every second track if it's requested or not (change WaitForPlayCount(1) to WaitForPlayCount(2)), or add a delay after waiting for the next track to play (change PAL.WaitForPlayCount(1); to PAL.WaitForPlayCount(1); PAL.WaitForTime('+00:01:00'); )
The delay is probably better, as it will still catch most requests (unless a short track less than a minute long, like a Jingle or Station ID plays before it) and doesn't explicitly skip tracks.