Trap signals and quit gracefully.