instead of "cleanup && exit1", you probably want "cleanup; exit 1", so you exit even if cleanup fails.