YouTube Video keeps on playing after closing Modal

I created many Modals, these modals contain YouTube videos. so i click a button, a modal pops up on my screen and there is a video inside. I play the video for a while and then i close the modal. The modal closes but the video keeps playing in the background and i can still hear the sound!! How can i stop the video when i close the modal? Please help... I tried many JavaScript codes that i found online but none of them worked with Bootstrap Studio, or maybe i didn't know how to load them!!

Is this happening on a live website, or in the browser preview? If it's a live website, post the link.

Is this topic solved already? Please can you share the solution because I have the same issue on

This script with stop the video when you close the modal

$('.modal').on('', function() { var memory = $(this).html(); $(this).html(memory); })