When a build fails, we can exit and leave ${PROFILE_DIR} behind. Make sure this is cleaned up with an exit trap. While we're adding a function, update the syntax of the others for consistency. Change-Id: I14499b5ebaaa30126aaa6b3d1bd86ed64f110fda