In season 12 of Two and a Half Men, Walden decides to become a father. However, a lawyer soon reveals to him how difficult it is for a single man to adopt a child. So Walden proposes Alan, who accepts the terms of that agreement. After the two marry, they meet with social worker Ms. McMartin (Maggie Lawson) about adopting a child. Things don’t get any better when Alan has an affair with Ms. McMartin and poses the imminent danger of the charade being exposed. In the end, however, Walden and Alan are actually approved and adopt a boy named Louis (Edan Alexander).
Not long after, Walden and Alan divorced. At the same time, Alan proposes to his girlfriend Lyndsay (Courtney Thorne-Smith). Happy for his friend but saddened by the loss of a roommate, Walden offers Alan the option of staying at the beach house permanently. Alan declines but reminds Walden that they will always be friends and he will still be around.
While that all sounds heartwarming, it’s fair to assume that had there been a 13th season of the show, Alan probably would have somehow found a way to move back in. The story makes it clear that no other option would have been possible for the show in the long run.