I actually failed recently on a project. I can't really mention details due to Non-disclosure agreements, but I was working on a project involving Google and I simply couldn't finish. I wasn't smart enough. It involved encryption that was just beyond my scope of knowledge.
I have never had to walk away from a project before, never had to tell someone I couldn't complete a task. It was such a strange feeling. I couldn't even do enough research to figure out how to go about passing the road block. I know that I don't know everything, but I never thought that I would run into a problem too complicated to even learn.
I can sympathize with this, though I haven't had quite the same experience myself.
I was rewriting an application that used a technology that had just reached the end of its life cycle (MS wouldn't support it anymore). After writing the application, we upgraded the server and the technology was no longer supported. I spent two months trying to implement the same solution with the newer technology. I couldn't do it.
What did I do? I told myself, "I can't do this right now. I just don't know enough about it." I found a workaround that allowed me to use the old technology on something other than the server. Over the next two years, I occasionally revisited the projected, hitting my head against that same brick wall until I had to admit defeat again.
When I turned in my two weeks' notice, I knew that none of my co-workers could pick up where I'd left off. I tried implementing the new technology again. With only one day left, I made a breakthrough, but I still couldn't get the implementation to work right.
I ended up leaving the project almost finished and tried leaving enough documentation for someone to follow in my footsteps.
In my case, I was able to put the project on the back shelf and revisit it from time to time. Unfortunately, you didn't have that luxury.