The rule I've heard repeated is "retreat from a knife, attack a gun".
Attack with “action at a distance”