If you generate more energy than you use you can sell it back to the grid OR you may like to consider a battery storage system, this option is becoming more and more popular. Rather than sell your excess energy back to the grid it can be stored in a solar battery. Solar batteries work by storing the energy that is produced by your solar panels and storing it for later use. Excess energy will only go back to the grid if your battery is full.
One thing to remember is solar energy of course comes from the sun. So if it’s overcast less energy will be produced, when the sun sets, no energy will be produced. In these situations you may need to buy energy from the grid to meet your needs, however if you have a solar battery storage system in place any excess energy your system produces will be stored and ready for use when it’s needed.