How do you close or preset a Dialog popup programmically when left open.

How do you close or preset a Dialog popup programmically when left open.

   How do you close or preset a Dialog popup programmically when left open. 
I have a condition when a user selects a link in my dialog box that takes them off-site to another website, this leaves my Popup dialog still open and even when i re-enter the mobile website the dialog is still active.
How can I make sure the dialog is closed and not cached and active until a user selects it.

I also have this condition with collapsable. how do i make sure they are closed and not cached if the user just  leaves one open and quits the web-app.


<p><a href="#popupDialog" data-rel="popup" data-role="button" data-inline="true">How to place an Order</a></p>


        <div data-role="popup" id="popupDialog" data-postion="fixed">
<div data-role="header" data-theme="a" class="ui-corner-top">
<h1>Place an Order</h1>
</div>
                    
                    <div data-role="content" data-theme="a">
<h1>To place a order you can call us at: </h1>
<p><center><a href="tel:541-899-8038">(541) 899 8088</a></center></p>
                        <br>
                        <p><h1>Or link to our website shopping cart.</h1></p>
                        
                        <p><a href="http://www.feed-back.com/shop/index.php?main_page=products_all" data-role="button"  data-theme="a">Feed-back.com Shopping Cart</a></p> 
                        <br>      
                        <p><a href="docs-dialogs.html" data-role="button" data-rel="back" data-theme="a">Cancel</a></p>    
</div>
       
          </div>