> Wait, can Congress do that?
Yes.
> I know that they approve budgets obviously, but I thought all they could do was allocate it to different departments. I didn't think they could say, "here's this money but you can only use it for this purpose.. you absolutely cannot use it for this other purpose".
Not only can they do that, that is usually how they allocate money. Even when there is some flexibility in how the funds are spent, that flexibility is defined in the law appropriating the funds.
> And it's hard to imagine them removing the military's authority from withdrawing from a war.
Withdrawing from a war is an unlikely thing for Congress to act to bar, sure, but that's not because they couldn't, just because they would be unlikely to choose to. Closing the detention facility at Guantanamo, well, that's a different story. While they haven't exactly prohibited it, they've removed funds for it from budgets and prohibited the specific steps the administration proposed to take to do it (such as transferring prisoners from Guantanamo to the US.)