How to close browser window with buttonclick?

Hi,
I spent hours and hours trying to figure out how to close the browser window from within the movie (on button click) - I have read thousands of posts and tried different methods, but nothing worked.

Here is the latest one that I was trying:

code for the button:

close_btn.addEventListener(MouseEvent.CLICK,onCloseBtn);

function onCloseBtn(myevent:MouseEvent):void{    
    var myurl:String="javascript:self.close()";
    var mywindow:String="self";
    ExternalInterface.call("closewindow",myurl,mywindow);
}

And I put this javascript code in the head of the html page

<script language="javascript">
function closewindow (){
    self.close();
    }

</script>

Does anyone have a solution?