An inverter  converts the DC electricity produced by your solar panels  into AC power, which is then sent through the main switch box  to either your electric load  or the electricity grid .
If the production of your solar system exceeds consumption, the power meter will run backwards and you will receive savings on your electricty bill.
If your solar system cannot produce enough electricity to cover the consumption, the grid can still supply the extra amount of electricity necessary.
Solar panels do not produce electricity at night and the grid covers consumption. A perfect size solar system will balance grid supply at night with excessive production during the day.