This is exactly how our rooftop solar works. The inverter only supplies ac power if it can sync to the grid frequency meaning that the system disconnects without a live grid connection. Even if I had a battery, this would still be a requirement under local regulations.