---
title: Stop Video When the Popup Closes
description: "If you embed a video to a Popup Maker popup using Popup Maker Lite (free version), you need an extra step. You'll need to make sure the audio stops playing when you close the popup. The following custom code examples…"
url: "https://wppopupmaker.com/docs/special-popups/stop-video-when-the-popup-closes/"
updated: "2026-10-21"
category: Advanced / Special Popups
---

# Stop Video When the Popup Closes

If you embed a video to a Popup Maker popup using Popup Maker Lite (free version), you need an extra step. You'll need to make sure the audio stops playing when you close the popup.

The following custom code examples show you how to stop your YouTube, Vimeo, and HTML5 video playing when your video popup closes.

Avoid the hassle of custom code.

[Get the Popup Maker Videos extension](https://wppopupmaker.com/extensions/videos/).

   **Note**: If you use any of these code snippets, replace the example [popup ID](https://wppopupmaker.com/docs/manage-features-or-options/find-the-popup-id/) (123) with your popup's ID number. Learn how to [find the popup ID](https://wppopupmaker.com/docs/manage-features-or-options/find-the-popup-id/).

## YouTube (no other query parameters in the src URL)

```
jQuery('#pum-123')
    .on('pumBeforeClose', function () {
        var $iframe = jQuery('iframe', jQuery(this)),
            src = $iframe.prop('src');
        $iframe.prop('src', '').prop('src', src.replace('?autoplay=1', ''));
    });
```

View the source on [GitHub](https://github.com/PopupMaker/Library/blob/master/Video/youtube-stop-on-close.js).

## YouTube (if already other query parameters in the src URL)

Follow this next YouTube code sample if you added the `autoplay` and `mute` parameters to the embed  `src` URL like this.

`src="https://www.youtube.com/embed/s-OoG1aGYO0?start=1&autoplay=1&mute=1"`

```
jQuery('#pum-123')
    .on('pumBeforeClose', function () {
        var $iframe = jQuery('iframe', jQuery(this)),
             src = $iframe.prop('src');
         $iframe.prop('src', '').prop('src', src.replace('&autoplay=1&mute=1', '')); // Remove the appended query parameters. Remove mute too if you added it before for Chrome.
     });
```

The code sample above removes the `autoplay` and `mute` query parameters from the existing query parameter list of the `src` URL.

Here's what the  `src` URL would look like after the jQuery code runs.

`src="https://www.youtube.com/embed/s-OoG1aGYO0?start=1"`

## Vimeo

```
jQuery('#pum-123')
    .on('pumBeforeClose', function () {
        var $iframe = jQuery('iframe', jQuery(this)),
            src = $iframe.prop('src');
        $iframe.prop('src', '').prop('src', src.replace('&autoplay=1', ''));
    });
```

View the source on [GitHub](https://github.com/PopupMaker/Library/blob/master/Video/vimeo-stop-on-close.js).

## HTML5

```
jQuery('#pum-123')
    .on('pumBeforeClose', function () {
        var $video = jQuery('video', jQuery(this));
        $video[0].pause();
    });
```

View the source on [GitHub](https://github.com/PopupMaker/Library/blob/master/Video/html5-video-stop-on-close.js).

  If you are **new** to using custom JavaScript in WordPress, check out our [getting started guide](https://wppopupmaker.com/docs/getting-started-with-custom-code/getting-started-with-custom-js/).
