Did your script open the window? Firefox 2 and later do not allow scripts to close windows that they did not open.
You could try this trick, but I have no idea whether it will work. I live on the side of the population that believes users should be in control of their browser windows, not applications (despite the fact you may have a good reason for this).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…