What you need is to write a macro that opens up ff (or any other browser) with the debugging url.
Then you can control it and close it when the debugging ends.
but i think this task is quite hard to implement.
who mentioned here to simply set the default debug browser is not answering your question at all, b/c it will not be closed...
With Firefox established as your default browser and Firebug installed, you can debug your script in Firefox. Select Tools > Firebug > Open Firebug. The Firefox instance now shows the debugging console. To enable script debugging, click the Console tab, check the Script option, and click the "Apply settings for localhost" option.