Check if you are using the exit(1) function correctly. It does mean you are exiting the program and not the function. Use break/return statement if appropriate.

Offtopic comment:
This is my 1,000th post by the way