Handle term signals gracefully.