Lifecycle Lab
Close the window.
Keep the work running.
A heartbeat makes the failure visible. Compare a view-owned task with an app-owned worker.
What the example checks
A view's .task stops on close while the app stays in the Dock and menu bar. Reopening resumes the count with a new task, hiding the failure.
The fix runs with no windows, starts only once, stops on request, and prevents an old run's cleanup from clearing a new one. It distinguishes closing the main window from closing the last window, and preserves Dock and menu-bar reopening.