You need to be careful exiting with codes above 255. Exit codes must be in the range of 0-255. 0 meaning success the other 1-255 are error codes. You also must avoid reserved error codes which have certain meanings.
cmp@cmp-dev:~$ bash --version
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Here is an exit 666:
$ bash
$ exit 666
exit
$ echo $?
154
It wraps at 255:
$ bash
$ exit 256
exit
$ echo $?
0
Stick with 255 and under and avoid reserved error codes (better the devil you know eh?)