In Season 12 of "Two and a Half Men," Walden decides he wants to be a father. However, a lawyer soon reveals to him just how difficult it is for a single man to adopt a child. So, Walden proposes to Alan, who accepts the terms of this arrangement. After the two are married, they meet with social worker Ms. McMartin (Maggie Lawson) about the possibility of adopting a child. Matters aren't helped when Alan has a fling with Ms. McMartin, introducing the looming threat of the charade's exposure. In the end, though, Walden and Alan actually are approved and adopt a boy named Louis (Edan Alexander).
Not long afterwards, Walden and Alan divorce. At the same time, Alan proposes to his on-again-off-again girlfriend, Lyndsay (Courtney Thorne-Smith). Happy for his friend but sad about losing a housemate, Walden offers Alan the opportunity to stay at the beach house permanently. Alan declines, but reminds Walden they'll always be friends, and he'll still be around.
While this all sounds heartwarming, one has to assume that if there were a Season 13 of the show, Alan probably would have somehow figured out a way to move in again. History makes it clear that no other option would have been possible for the show long-term.