Creating and disposing of PApplet windows

In Processing 4 the sample code shows how to create multiple windows, but not how to destroy them. All help threads are old and the code I found does not function in version 4. I do not merely wish to hide a window, but destroy it in a correct fashion, after freeing all resources.

winOne w1;
winTwo w2;

void setup() {
    surface.setSize(300, 300);
    surface.setTitle("main application");
    surface.setLocation(200, 200);
    surface.setVisible(true);
    colorMode(HSB, 1.);

    w1 = new winOne();
    w2 = new winTwo();
}

void draw() {
    background(color(.2, 1, 1));
}

void keyPressed() {
    if (key == '1') {
        w1.toggle();
	    surface.setVisible(true);
    }

    if (key == '2') {
       	w2.toggle();
	    surface.setVisible(true);
    }
}

// other applet classes

class myApp extends PApplet {
    boolean running = false;
    
    void toggle() {
        if (!running) {
            String[] args = {""};
            PApplet.runSketch(args, this);
	        running = true;
        } else {
            running = false;
	        // dispose(); erk??
        }
    }
    void settings() {
        size(300, 300);
    }
}


class winOne extends myApp {
    void setup() {
        surface.setTitle("window one");
        surface.setLocation(600, 200);
        colorMode(HSB, 1.);
    }
    void draw() {
        background(color(.4, 1, 1));
    }
}

class winTwo extends myApp {
    void setup() {
        surface.setTitle("window two");
        surface.setLocation(1000, 200);
        colorMode(HSB, 1.);
    }
    void draw() {
        background(color(.6, 1, 1));
    }
}