Forget vehicle to grid and think vehicle to home instead
The power flow is controlled via communication between vehicle, charging stand and a home energy management (HEM) system. The HEM system would need some kind of schedule or signal from the utility to know when to charge and when to send power back.
Links to more information: