Nice, in this case the solution is really easy, just a switch that the grid operator can turn off to cut the solar panels off the grid when there is not enough demand.
That's how it does work now, at least in Australia, the energy meter on your house is connected to the internet and when the market rate goes negative (oversupply) solar production gets disconnected.
If you've got a battery you can continue to charge it, as well as consuming power from your own panels, but you won't feed back power at these times.
If you've got a battery you can continue to charge it, as well as consuming power from your own panels, but you won't feed back power at these times.