Good question. That can happen - though it's usually for more junior roles. In that case I give them a take home task. The important thing here is that whether or not the result is good, I commit to talking it through with them (provided it works).
You might ask "why spend your time walking through code for a candidate that won't make it through?" Well, it's important for me that if people aren't a good fit for the role, they would be happy recommend us to people that they think are a good fit. Interviewing with that mindset ensures I (and my team) treat candidates like people, instead of like numbers.
In the spirit of the actual Ask HN though, I have had a small number of candidates that were deceptive, or difficult. In those cases it's just a polite but firm "I'm going to have to draw this call to close because <xyz /> and I don't want to string you along." Fortunately I've not had a person different to the interview show up on day 1 though... that'd be a little more awkward.