On my system they installed a power meter that goes both ways. It monitors the energy I use from the grid and it monitors the energy I send to the grid. When the solar panels make electric the system monitors the voltage from the street and then sends it from the panels to the breaker box at a slightly higher voltage. This higher voltage is like a switch as all of your energy devices will use the higher voltage first as it is more efficient and any unused energy is released into the grid. The energy sent back into the grid is a slightly higher voltage and your closest neighbors will use your energy before they use the energy from the power company.
At the end of the month I pay what I got from the grid after they deduct what i sent to the grid. In the summer I make more energy than I use so the power company banks it in my account. Every month that stored energy is credited to my account and on April 1st every year if I have any energy in the bank they send me a check for the balance.
Hope this helped.