EDIFFG defines the break condition for the ionic relaxation loop. If the change in the total (free) energy is smaller than EDIFFG between two ionic steps relaxation will be stopped. If EDIFFG is negative it has a different meaning: In this case the relaxation will stop if all forces are smaller than EDIFFG . This is usually a more convenient setting.
EDIFFG might be 0; in this case the ionic relaxation is stopped after NSW steps.
EDIFFG does not apply to MD-simulations.