I am not a lawyer and I have never even been to the UK.
You will not go to prison if your neighbor's dog attacks you and it dies as a result of you defending yourself.
You might go to prison and/or owe the owner damages if:
- You are somewhere you do not technically have a right to be.
- It can be shown you could have retreated from harm but chose instead to stand your ground.
- The force you used was deemed excessive - it showed intent to harm the dog more than necessary to protect yourself
- You contributed to the confrontation in a way that a reasonable person would think might cause trouble
You might be able to protect yourself from problems by:
- taking pictures or videos of the dog behaving badly or aggressively
- note dates and times when you observe the dog behaving badly or aggressively
- formally contact the dog's owner with your concerns and/or evidence in which you assert your rights to access the areas you walk through and your right to defend yourself in the event that you are attacked by the dog
- if possible, change your route or schedule to avoid the problem entirely