Gallagher was recalled by parent club Southampton on Wednesday, with MK Dons manager Karl Robinson thanking the player for his time at the Championship outfit.
"Sam's attitude has been spot on and he's always given everything - it's unfortunate that things haven't worked out," Robinson told MK Dons' official website.
"He has found opportunities limited and it's vital, at his age, that he is playing games on a regular basis and we never want to stand in the way of a young player doing that.
"We are thankful to Southampton for their help and co-operation. I have no doubts that Sam will be a top, top player in the future and we wish him all the best."
During his spell at the Stadium:mk, 20-year-old Gallagher made 15 appearances in both the Championship and cups competitions for MK.