Macroeconomics, the circular flow of income and profits
The firm broke the circular flow of income in your example; profits went into a black hole.

Imagine that the firm instead distributes all profits to the owner, who spends all proceeds.

The firm gets \$6000 in revenue, pays \$5000 in wages, and pays \$1000 in dividends. The wages and dividends are enough to provide the revenue.

I am ignoring the issue of the initial money holdings. There is a number of ways these transactions can be supported: credit, or the \$1000 dividend was paid out revenue as it came in. 

In order to respect the initial money holdings, and have sales of \$5000, what happens is that the firm has excess inventory (with a sales value of \$1000). That is, the workers could not afford to buy all of the output. The firm would be profitable, but with zero cash flow. Since the cash used to pay the workers returned to the firm, it would be able to then pay a dividend out of profits. That dividend could then be used by the owner to buy the remaining inventory.

It is not obvious how the firm can forecast its profits exactly in this fashion, but that would be covered up in an economic model by solving for all flows simultaneously. If all cash flows are settled simultaneously, we actually cannot see how the money flows work; we only see the net movement.