What happened to German POWs after a country they were housed in or captured by surrendered?

I don´t know how many germans were captured during the invasions of poland, scandinavia, the benelux and France, but what happened to the ones that were after the respective nations surrendered? Were the soldiers released an dfree to return to the army, or were they hastily moved to britain before their countrymen could release them?