The traditional way to fund maintenance was to release a new and better version of the product. Example, all the releases of the various office suites from the days of MS-DOS up to Windows up to the cloud. If sales decline, sell to a competitor (good timing required) or close and switch to something else. A company that paid salaries for 5-10 years is still nothing to be ashamed of.
In the case of Apple, keep selling new hardware. I can't remember if they ever sold their software in the first years of Macs or if it was bundled with the hardware.