The one and only purpose of the Castle Doctrine is to give a person legal protection against prosecution if they are involved in a legitimate self defense situation that involves the use of lethal force.
It is not enough to shoot at the "perception" of danger. If the shooting involved ambigious circumstances, then you are still going to go to trial to determine whether you acted rationally or not.
The Castle Doctrine will not save you from jail time if you shoot someone in the back while they are running away or if you shoot through a door, although the specific circumstances will have bearing in the case.
The Castle Doctrine is not the same as being given the "00" designation in Her Majesty's Secret Service, but some people believe wrongly that it (almost) does.
Both the "00" designations and a persons protection from prosecution in anything less than a clearly justifieable shooting are myths.