Rule 3.4.5 says "....A period shall not be extended by an untimed down if.... fouls, for which enforcement by rule result in a safety"
This seems a little unjust to me, because if team B is behind and they had just forced safety due to foul on A then you would think team B would have a chance to return the safety free kick.
Also, am I reading this correctly? Is my understanding that a safety, that is not the result of a foul, does extended period to one untimed down if so, why the difference?