[Csnd] stop csound


in my livecoding, when I render an algorithmic score as .wav I call the score with the -o test.wav flag.
If I want to stop after some minutes of recording I need to call an instrument with the exitnow() opcode.
I just discovered that in this way, csound does not end writing the .wav file properly (e.g. Max doesn't want to read them - anyway all the others programs like Reaper does not have problem). Anyway, I understood that I'm forcing csound to stop.

I tried to make an instrument after some time that with turnoff for all my alwayson and schedule(.., 0, -1) instrument, but csound freezes.

Is there an opcode or a way I can properly clean exit from csound?
It's almost like pressing the stop button in CsoundQt, I tried for exemple to press the stop button and export a .wav file and the .wav is properly ended.

Thank you,


Csound mailing list
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Platform? Version?

Get TypeApp for Android

im sorry… i always forgot

macOS 10.15.7
csound 6.17

Try using the opcode

event("e", 0, 1)

when you want to stop (it's a k-rate opcode).
For example

instr 2
event("e", 0, 1)

instr 1
a1 oscili 0dbfs,440
out a1

Ohh, amazing!
It works like a charm.
Thank you very much!