Nevermind. I figured out that when using a function – not a script – I need to return [n] instead of exit [n]
return [n]
exit [n]