Now that I know more about the game I have a list of solutions:
- Switch to peaceful mode to despawn the witch
- Run far enough away to despawn the witch
- Change to creative mode to get invulnerability
- Command give items to yourself to fight back including golden apples
- Build a wall around her to block her in until you get the weapons you need
The cause of the problem was I was setting the torches too high up to get sufficient light coverage on the ground below.