I've used a variation of this that catches other signals as well:
trap 'rc=$?; trap "" EXIT; cleanup $rc; exit $rc' INT TERM QUIT HUP
trap 'cleanup; exit' EXIT