The energy spent to get the car to the top of the hill is spent to get the car to the top of the hill, not to charge the batteries. Now that the feat has been accomplished, if you want to get to the bottom of the hill, you have to dissipate some energy. You might dissipate it as heat, or you might put it into a battery.
Next time you go up a hill, some of the energy that you need can come from the batteries, and some from gasoline.
It's not perpetual motion, but it's not all lost either.