Most if not all of the people commenting in this thread so far appear to be in PG&E territory. I assure you that Net Metering works the same way throughout PG&E territory. In any given month and any given TOU period, any negative kWh total gets full retail credit. The dollar amount for the month is rolled into your true-up totals. This total is treated in one of 3 different ways.
1. You owe a dollar balance at true-up. This balance is the total energy charges. Your minimum charges that you have paid throughout the year month by month are subtracted from this total to find the final amount that you owe.
2. You have a dollar credit balance at true-up, but you are a net consumer of kWh. You owe nothing and are paid nothing. This credit balance is wiped out because you are not owed Net Surplus Compensation.
3. You have a dollar credit balance at true-up and are a net generator of kWh. The total surplus kWh that you generated is added up and you are paid "wholesale" for that surplus. That amount has historically been $0.03-$0.035 per kWh in recent years.
This gets a little more complicated if you are on a CCA which has become the default in San Mateo, Santa Clara (except San Jose), and Marin County. At least for Silicon Valley Clean Energy, you are paid the typical Generation price for all net generation. So, if you are in category #2 above, you will get a check or a rollover credit from SVCE where you would get nothing pre-CCA. I'm pretty sure PG&E will still wipe out all Distribution credits for category #2 and #3 above at true-up.
Now, about PowerWall. It appears that the PG&E battery interconnect agreement does not allow pushing power from the battery into the grid. At all. That does not mean that you can no longer be a net generator, it just means that the battery will only satisfy loads behind the meter (in your house) and any generation that passes into the grid must be coming from your solar system, which is still allowed to feed into the grid for Net Metering credits. This is the main reason that I want TOU controls on my (future) PowerWall. I don't want to "waste" my battery energy charging my EVs overnight because the value of energy is lower overnight than my solar generation (Off-Peak vs. Part-Peak). If I can prevent the PowerWall from discharging during Off-Peak period, my starting SOC will be higher in the morning and will be full earlier in the day from my solar generation. That will allow my solar to earn me more credits in the afternoon while still eliminating my household usage during the Peak rate period through 9pm well after my solar has stopped generating. This does not violate the battery interconnect rules and gives me the best arbitrage benefit while also flattening the "duck curve" for the utility.