As a rule, you should always stop when a traffic light is yellow. Only continue driving if you are so close to the traffic signal when it changes to yellow that you risk causing a dangerous traffic situation by braking hard or suddenly stopping.
For example, if you drive at 70 km/h and are very close to a traffic light when the signal changes from green to yellow you should not try to stop. Braking hard 10, 20 or 30 metres before the traffic light would only result in a dangerous traffic situation as the stopping distance at 70 km/h is 43 metres (in ideal conditions).