Some of the violence in Iraq is caused by the presence of occupying troops there.
Some of it is caused by rival factions within Iraq.
If the Iraqi government can get to the stage where it is able to control the country and hold it together with just its own forces, the whole regime-change process will have been, by some measures, a success.
Opinions differ as to how likely that is. I am going to assume for the purposes of this discussion that there is a realistic chance it will happen.
If this stage is to be reached, there will come a point where the dangers of staying outweigh the dangers of leaving. I think it would be very optimistic to think that the country will be completely stabilised and pacified while a substantial US and British military presence remains.
Because there is a deep-seated tendency to overestimate risks which are completely outside one’s own control, compared to risks over which one has some control, when that point is reached, it will look as if it is still a long way off.
That is, at the optimal time to leave, it will look far too early. The risks caused by leaving will appear greater than the risks caused by staying.
The time might even have come already. I think there is a considerable risk that, if the Iraqi government were left to try to manage on its own now, it would fail. But there is a risk it will fail anyway. The question is which risk is greater, after correcting for our own biases.
I do not pretend to have sufficient knowledge of the situation on the ground to answer whether the time has come. But, just playing with the basic principles, I am fairly sure that when the time comes, it will not be at all obvious.