Most glue in bottles consists of two components, some synthetic chemicals called polymers and a solvent that prevents the glue from drying or sticking. When glue is used to join two things together, the water in the glue evaporates, allowing the polymers to bond the items glued together.
If we keep the glue bottle tightly closed, there is very little air captured in the bottle. Hence a very minute amount of water in the glue evaporates, which is not enough to dry up the whole bottle. The air in the bottle is usually insufficient for enough solvent to evaporate and dry out the complete glue. Hence glue bottles are recommended to be tightly closed. This is why, sometimes, a nearly-empty glue bottle might dry up.