I like the question, and I think I could do it at my house; but for most of us I don't think we have a practical solution.
I have 26 photovoltaic (Solar Electric Generation) panels on my roof. They feed a synchronized ABB grid tied inverter that is connected to the electric power grid. The inverter is synchronized to the power lines feeding my house.
When the sun shines brightly the panels make more electricity than I use and the surplus makes my meter run backwards.
When I use more than I make, my meter runs just like everybody else's.
The inverter will not make AC from the panel output if the electric power is out. This a safety feature.
My theory , yet to be confirmed, is that if the power grid should fail I could disconnect my home from the grid and then feed my house from my generator. The solar inverter would then be in parallel with my generator.
The inverter would then synchronize to the generator.
Because I do not own the panels or the inverter, I am not about to endanger my contract by experimentation.
The governor on my generator has been tested under load; from a 1% to 50% load change the frequency momentarily dropped only one half cycle. IMHO that is pretty good for a 13 horse Chonda (Chinese made Honda clone) spinning a 10 KW peak rated, HF alternator.