Add exit traps to build and install scripts