Although I gave Bob Baerker's answer a vote I should add that in general the large IPOs that people hear about (and all in some "western" countries thanks to legislation and market rules) are backed by one or more investment banks. This means that a bank will sponsor the listing on the primary market and guarantee a certain price level within acceptable limits. This usually means that the company can guarantee a minimum value for its shares. Within the contract for the IPO with the bank there will be various cancellation clauses which would trigger if the funding round is a disaster and the subscription level is far too low (so the bank will not guarantee the funds).
It is unusual, however, that these provisions are triggered and most IPOs that are cancelled are done so via an agreement with the bank and exchange that they will not receive the funding that they require from the IPO or that completing the IPO will have a destabilizing effect on the company or the exchange. It will normally be the investment bank who decides whether the IPO will go ahead or not based on whether it will take the risk of potentially owning a loss making position in the company. The reasons Bob mentions will inform the bank as to whether to continue its support.
In comments you ask when a company is considered "public". A company is public when any of its shares are publicly traded on an open exchange. This does not necessarily have to be the result of an IPO as private shareholders could, in theory, sell off their share of the business to receive personal capital. In this case no money would go to the firm itself and it is exceedingly rare that this happens.