if you leave somewhere with your tail between your legs, you leave feeling ashamed and embarrassed because you have failed or made a mistake
Usage notes: Dogs often put their tail between their legs when someone has spoken angrily to them.
The losing team walked off with their tails between their legs. See