var b = {x:window.screenX,y:window.screenY,state:document.documentElement.getAttribute("sizemode")};
window.moveTo(1000,1000);
gBrowser.removeTab(gBrowser.mCurrentTab);
window.minimize();
window.addEventListener("focus", xfocus, true);
function xfocus(event){
window.removeEventListener("focus", arguments.callee, true);
window.screenX = b.x;
window.screenY = b.y;
if (b.state == "maximized")
window.maximize();
}