Depends upon how the interview process has been structured.
If you are on a phone screen with someone and they are having problems, then maybe just switch over to easier questions or give them one more before wrapping things up and saying you will be in touch. These generally aren't expected to run long so you have the advantage of being able to end it gracefully without anyone feeling like they have been flatly rejected.
If you are conducting face to face interviews things get a bit trickier as you have to make sure your time isn't wasted as well as the candidates since they may report back on their impressions of the interview which might turn off another candidate that you may want. If you have a day long interview scheduled with multiple people, then at the lunch break time could be a good time as it will give some of the interviewers time to touch base and give their early impressions. If the candidate knows ahead of time that you may end things after lunch then they shouldn't take things too hard and if you pay for their lunch it will smooth things over quite a bit.
If you have less then a day worth of interviews lined up (i.e. before lunch or after lunch) then it really depends upon how they are doing during the interviewing process and what positions you have open. If someone is interviewing for a mid-level position but you have a junior position open an they seem like a good over all fit they might still accept a job offer if you tender one in which case it might make sense to continue with the interview but adjust the questions.
If they are doing poorly due to technical issues then Brandon DuRette's answer raises a good point in which you should just be honest and tell them what the short coming is. Most developers will appreciate this as they know where their weaknesses are now and can focus on improving as opposed to just an early end which leaves you wondering what you did wrong. To add to this a bit though, if you are using some sort of white board question, just show them the sort of answer you were looking for or explain it real quick before they go. This is one of those things that some developers will really appreciate so they can see how off target they were during the process.
If they are doing poorly due to personality conflicts then things are going to be a bit tougher as it can cause hard feelings depending upon how it is done and what is said. This is an area where having someone coordinating the whole interview process can help as that person could be responsible for letting the candidate know if they got the thumbs down from someone. Likewise, you might want to talk to someone in human resources for advice here because just saying you don't think the candidate would fit in with the company culture could leave the wrong impression if done the wrong way.