The Short Answer
Strictly speaking, you are correct: a government shut down does not involve the government "running out of money." A more accurate statement would be that the government isn't allowed to spend its money. The process for raising and spending public money involves checks and balances (many of which were inherited from Britain, some of which are home-grown) mainly between Congress and the president. The two main constraints that cause government shutdowns are expiring appropriation laws and the Antideficiency Act.
What is an "Appropriation?"
An "appropriation" is a permission slip from Congress to take money from the Treasury. The Constitution prescribes that "No money shall be drawn from the treasury, but in consequence of appropriations made by law" (Art. I, sec. 9). This means that no one can spend any money out of the Treasury unless Congress first passes a specific law (i.e. an appropriation) allowing it. Without an appropriation, attempts to spend money would be illegal, and beyond the inevitable political costs, could trigger both impeachment proceedings and court cases (courts, for example, might hold that an action taken pursuant to illegally spent money was not proper and thus legally null and void).
The Constitution also specifies that Congress has the power "To raise and support armies, but no appropriation of money to that use shall be for a longer term than two years;" (Art. I, sec. 8). This means that at least in the cases of the Army, an appropriation must expire within two years. While Congress is not required to do so, they have decided over the course of 230 years that time limits on appropriations are a good practice, and so almost all government departments are funded through annual appropriation laws. (There are some important exceptions, such as Social Security and Medicare, which Congress has decided deserve permanent appropriations.)
How does Congress appropriate money today?
Today (2019), there are a total of thirteen appropriation laws that Congress must pass each year before the 30 Sept. deadline when the current fiscal year ends and its appropriation acts expire. However, Congress rarely meets the deadline to pass all thirteen appropriation laws, and thus Congress opts to pass what are called "continuing resolutions" (often abbreviated CRs). Continuing resolutions tend to expire within a few weeks to a few months, and usually enable the government to spend money at a level comparable to the previous fiscal year's appropriation law. For example, if the Commerce Department's appropriation law had not yet been passed by 15 Sept. and the Commerce Department's budget for the current fiscal year was $50B, Congress might pass a CR that expires in mid-November that allows Commerce to spend $8.3B, the pro-rated amount (this is a simplification, but illustrates the point). When Congress can finally achieve political consensus to pass an appropriation law, the CR is superseded and the government department is funded through the rest of the fiscal year.
Keep in mind that I'm painting in broad strokes here. Congress could decide that the EPA can only spend money when the phase of the moon is "waxing gibbous," and that would be the law. They tend not to pass laws so absurd, but little beyond politics is stopping them from doing so. A more realistic exception might be that Congress allows a particular agency that generates user fees to spend that money as long as they have it.
What is the "Antideficiency Act?"
The other really important constraint is a law passed in 1880 called the "Antideficiency Act." The executive branch in the 19th century tended to create unfunded obligations that Congress would then have to pay for after the fact. The Louisiana Purchase is one famous example - President Jefferson made a deal with Napoleon to buy Louisiana absent a Congressional authorization, and then Congress was more or less obligated to foot the bill. For another example, by the late 19th century, the military might sometimes "run out" of money two months after receiving its appropriation, leaving Congress to scramble to fund the remaining months of the year and the return of the troops.
Congress finally got tired of the executive branch creating these "deficient" obligations and so passed the Antideficiency Act, which regulates exactly how and when the government can make promises or receive anything of value (hint: Congress usually wants to know). The Antideficiency Act, for example, forbids the government from promising government employees back pay, as this would create an obligation (in practice, Congress has always provided back pay when they finally fund the government). When an appropriation expires, the Antideficiency Act prevents the government from promising that Congress will pass a new one, so the government agencies and departments without active appropriations must usually shut down. While a lack of appropriation laws prevents government employees from getting paid, the Antideficiency Act is what keeps them from going to work. In a very real sense, the reason we have government shutdowns on exact dates is the Antideficiency Act.
Summary
The executive branch can only spend money with an appropriation from Congress. Appropriations expire. The Antideficiency Act makes it illegal for the executive branch to make promises or accept certain gifts without Congressional approval, which means that government operations must cease when appropriations expire.