How to gracefully walk away from coauthored paper
This is more a warning of the consequences than a real answer. There may not, in fact, be a way to do this gracefully. 

You need to decide what the paper will become without you. Technically, they can't publish it without your permission. If you aren't a co-author, will you want acknowledgement? Will you want your name listed at all? 

If you don't want your name listed and you have contributed to it, then publishing it could open the others to a plagiarism charge. 

So, the situation is a bit sticky. If the paper can't be published without you, then there could be hard feelings and sometimes such things are a bit "sticky". 

I suggest that you need to work out the details with them, to just withdraw. You may have some leverage to improve the paper and stay on the list of authors. But you might need to take some responsibility for the project to accomplish this.