You can set up an emergency power bus that powers from either grid powered charger or solar powered charger. The system will automatically operate from whatever power is available, and will not backfeed when the grid is down.
This is the mechanism behind your computer UPS systems, just scale it up to a larger size, and power your essential circuits.
Commercial buildings and hospitals have backup power systems. Those systems do not try to power the entire building, just the emergency bus. Switching from grid to backup power is either automatic or manual, depending on hardware installed, and no chance of backfeed.
Hmmm, I’ll have to talk with my solar pusher about that. thx.