See the test code below;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<script type="text/javascript">
var theWindow;
function openGoogle() {
theWindow = window.open("http://www.google.com/", "_blank")
}
function closeWindow(aWindow) {
aWindow.close();
}
</script>
<input type=button onclick="openGoogle()" value="open google"/>
<input type=button onclick="closeWindow(theWindow)" value="close the window" />
</body>
</html>