Once a player donates his shards to the guild, the guild first converts shards to credits 1:1. Then the guild owns those credits and can use them to purchase various guild upgrades or flags.
A player cannot withdraw guild credits. Once you donate the shards, it forever belongs to the guild. It isn't your credits for the guild, but rather the guild's credits for the guild to spend.
Only the leader has authority to spend guild credits.
If you leave, or get kicked from the guild, you do not get a refund on your shards.
UPDATE: If you leave your guild, and then rejoin it, you don't regain your previous donation counter. Everyone starts back at 0 when they join a guild, even if you are rejoining.