Is it OK to decline a review request after multiple resubmissions? I have served as a reviewer for a few journals multiple times, and I typically take the task very seriously and aim to provide informative and constructive reviews. However, there's this one case that has me struggling for a while.

I got asked to review a paper that is only partially related to my field of expertise, probably because the paper is rather interdisciplinary and the editor ran out of reviewers with expertise in all areas tackled by the paper. I accepted happily at first, but the thing is that the paper just isn't very good. In the first round of reviews all reviewers oscillated between "major revisions" and "possible reject." Now it is the 4th resubmission, and although the authors appreciate and follow the reviewers' suggestions, they often introduce new mistakes when addressing the reviewers' comments and the overall quality of the manuscript remains poor.

Now I'm considering declining the invitation to review. I feel like I've spent more than enough time trying to understand this paper and giving (hopefully useful) feedback, but this is becoming an endless cycle and I'm losing confidence in my ability to judge whether the paper is above or below the borderline. On the other hand, I appreciate the authors' efforts and I feel like it might be impolite if I drop out of the editorial process at this point.

Does anyone have any thoughts on this?

Note: my question is somewhat similar to this one, but there are several differences that IMHO justify asking a separate question.
That's a tough situation and not one I've run into, so I can't speak from experience.  In your place I think I'd decline to review, and directly contact the editor to explain your position. (If the review request doesn't have an explanatory text box associated with it, then email the editor directly.)  Something like "The authors have been cooperative but the paper quality has remained low for multiple revisions, and at this point I have no more constructive comments to give on this paper.  Unfortunately, my time doesn't permit another review" seems fair and clear enough.