The rules in Illinois are you net meter for the year. If you make more than you use in a year that is free power for the utility. If you want a different deal you need a contract with the utility (In general you need to be in the millions of dollars/year range to be of interest). In Texas it is more complex as each provider can give you a different deal for residential systems.
When the grid is down you can't sell power back. The whole system shuts down. Though if you have a whole house battery backup you can use that instead of the grid (if it is built for it - solar gets weird if you aren't using exactly as much power as you make so you need something to use or make up the difference).