I am programming in circuit with PicKit 2 which has suddenly decided to stop the circuit working if I disconnect it.
Sounds like a MCLR issue. Try _MCLRE_OFF
in your configs.