It is better to take too much food on a sailing trip than too little, so there is often something left at the end. You do not have to throw it away.
Leave it on the boat for the cleaning team
Pack unopened food that is still good into a bag and leave it on board with a note for the cleaning team. They can pass it on to the next guests.
Leave it at the marina
Some marinas have a shelf, often in the marina office, where sailors leave provisions for each other. You typically find basics there such as oil, salt and pepper: things you cannot buy in small amounts and rarely finish in a week.
Ask the charter office
For things like cleaning products, ask the charter office whether they can use them for future charters.