Okay, I found the issue.
I had used SetErrorMode(2) . Once I commented that out I didn't get the Runtime Library error. Instead it takes a second or two and then the game exits without error.
Is this behaviour expected?
Basically what I had was:
if JoinServer() = -1
end
endif
The JoinServer() function attempts to connect to a multiplayer game. If it failed then errors were thrown (e.g. socket timeout) and then the function returns -1. Under those circumstances I got the Runtime Library error when it attempted to end.