As the error message says you have run into a function declaration.
This isn't supposed to happen during program execution and is usually caused by you not having a
end instruction after your main program code (that doesn't reside in functions).
It could also happen if you throw in a function declaration in the middle of your code for some reason; you can't do that but I don't see why anybody would place it there either.
Likely your problem is just the missing
end statement, in which case that error only occurs after your program has essentially "finished" anyway. Throw it in at the end and it should close normally.
"Why do programmers get Halloween and Christmas mixed up?" Because Oct(31) = Dec(25)