They'd continue failing until they had success. They could weather Wii U level failures for over 30 years before running out of money because unlike most businesses, they are extremely frugile and efficient with spending of money.
Unless Nintendo loses their minds and makes failure after failure (like 5-7 of them) or started spending money like other businesses do, they are pretty much safe from ever leaving the hardware industry. Probably safe through at least 2050 from leaving the hardware market, AT LEAST.