Send "stop" to running loops

Hi chums,
I’m trying to send a stop message to a running loop - for various reasons I cannot use the more obvious n.times do-end method. The following is wrong and doesn’t work, but illustrates my pseudo-code wishes: after a certain time, stop a running loop.

live_loop :play do
  play 55, release: 0.5
  sleep 0.5
end

live_loop :cease, delay: 8 do
  cue :play, stop
end

Thanks
PD-Pi

live_loop :play do
  stop if get :stop_flag
  play 55, release: 0.5
  sleep 0.5
end

at 8 do
  set :stop_flag, true
end
1 Like

Perfect, thanks

PD-Pi