A bear does not need to be "pursued" in order to be provoked into an attack. Bears are known to sometimes attack at the shot. They don't always run away.
That said, I prefer a handgun to pepper spray.
I'd rather have a 12 ga. over a handgun and a rifle (of almost any cartridge) trumps all.