Popup window does not disappear after button click

Hi, when I click on the movePlayer1 button (the image is not shown here) the two images shown below appear. The ‘popup’ image has a question and the ‘yes-up’ image superimposed on it. once I click on yes, the code runs (the code is replaced with // below for brevity). However, both images are not cleared from the screen as desired after the yes click. The popup is supposed to disappear on clicking yes.For no, there should be a way of closing the window too.

       movePlayer1.on('pointerup', function () {

		    var popup = this.add.image(400, 300, 'popup');
                        var button = this.add.image(popup.x, popup.y + 50, 'yes-up');
                        
                        button.setInteractive();
                        
                        button.on('pointerdown', function() {
                            button.setTexture('yes-down');
			//code will be placed here
                        });
                        
                        button.on('pointerup', function() {
                            button.setTexture('yes-up');
                        });
                        
                        popup.on('pointerup', function() {
                            // close the popup window when it is clicked
                            popup.destroy();
                        });
		}

popup error

It looks like you would do

button.on('pointerup', function() {
    button.setTexture('yes-up');
    popup.destroy();
});

Thanks, I also added button.destroy(); for it to work