“Scrubs,” the surrealist hospital sitcom that spent seven seasons as a stepchild of NBC’s schedule, has come close to cancellation more times than its creator, Bill Lawrence, cares to remember. So it’s a surprise, even for Mr. Lawrence, that the show is getting to write its own ending.

Well, some sort of ending, anyway  on a new network. In a rare move for network television, Mr. Lawrence’s “Scrubs” is moving to ABC, beginning Jan. 6.

“It’s freaky,” Mr. Lawrence said in the former hospital room that he uses as an office, between editing sessions of the forthcoming episodes. “I can’t believe we get to do it. It’s incredibly odd in this landscape to actually get to end a show.”

Even the end might be in question. This season will be the last one for Mr. Lawrence and the show’s star, Zach Braff. They have already taped what they call a series finale.