You are correct that if the generator provides a stable enough waveform for the inverter to qualify it as grid power, then it is possible that the inverter will try to backfeed the generator if the load drops too low. The simplest way to deal with that is to simply disconnect the solar when switching to generator. It might be difficult to provide a foolproof interlock for the backfed breaker though. If the solar breaker and the generator inlet breaker were adjacent it would not be too difficult. But the generator inlet needs to be adjacent to the main for interlock and the solar will typically be at the other end of the bus.