Having "exit 2" in the trap for 0 will cause the script to always return 2.
See installer/functions:settrap.
Any reason TERM is in there?  I believe it's covered by 0.