The gallbladder has the primary function to concentrate and store hydrophobic bile but also to regulate blood cholesterol. Consequently, the bile can become very thick at times depending on many factors. The three common factors are high cholesterol, low bile-salts and poor contraction. Commonly, it clears itself but if it doesn't proteins in the bile tend make it become congealed, plasticised and turn into sludge; cholesterol crystallises and form ultra-sonically detectable gravel and finally full sized gallstones. Note that there are other types of Gallstones that form differently. Thickened bile will melt in air, usually in 24 hrs; the longer in takes the greater the degree of solidification.
When the biliary chemistry isn't balance then the bile will start to congeal. This is what happens after a Liver Flush for up to 12 days until the bile salts are replenished.
There are many occasion that cause bile to become congealed. A common example is in pregnant women where the changes in hormones and pressure on the abdomen cause cholesterol level in the to change and the gallbladder to contracted less effectively. Illness, drugs and lifestyles can have the same effect.