If you're in the position of being able to refund any money you have received for which you didn't already clearly deliver whatever you promised, you can walk away with reputation in a pretty good place.
E.g., I got in way, way over my head on a project for a startup once a few years ago. They didn't know what they needed, and I had no true idea how much work was involved. When I couldn't deliver I returned the money (which hurt, but I could do it). The client later came back to me (!) with a much smaller, better-defined project which I executed on well. They became a regular client and have been worth six figures to me over the years. (It did help that they tried another developer in the meantime who also didn't deliver but kept the money and stopped returning calls.)
E.g., I got in way, way over my head on a project for a startup once a few years ago. They didn't know what they needed, and I had no true idea how much work was involved. When I couldn't deliver I returned the money (which hurt, but I could do it). The client later came back to me (!) with a much smaller, better-defined project which I executed on well. They became a regular client and have been worth six figures to me over the years. (It did help that they tried another developer in the meantime who also didn't deliver but kept the money and stopped returning calls.)