Unfortunately, there is no standard event to know when the selection window is closed or open, so your code will be quite hairy with placement for different browsers. However, I think it can be done, and I got something for you in Firefox using the mouseup event:
http://jsfiddle.net/FpfnM/50/
In Firefox (and I assume Chrome) you will need to carefully monitor the status of this element. When the escape key or blur event is pressed, you need to update the state to identify it as closed. I did not implement this in my demo, and you can see what happens if you press escape rather than clicking on the selection.
Safari made it easier where the mousedown event in select means opening a selection, and any closing of a selection means a click event.
If you find a browser in which none of these events fire, you can try another trick. Since form widgets, such as select and textarea, are often displayed by the operating system rather than inside the browser, it is possible that you may interact with them, and some messages may not fall into the browser event handler. If you placed a transparent text area that would close the screen at a lower z-index when the selection box is open, you can use it to track this closed click. It can catch events that may be missing a browser DOM element.
Update: Chrome sees multi-downs when selecting when it opens, and the mouse button in the document when the page is clicked using selection. Here is the version that works with Chrome:
http://jsfiddle.net/FpfnM/51/
Again, you will need to do some browser detection to deal with the correct behavior in each of them. One catch with Chrome, in particular, is that no event is fired when you click a second time to close it. However, you may notice a click on the page.
Short description:
Chrome/Safari: select.mousedown on open, document.mouseup on close Firefox: select.click on open, document.mouseup on close IE8/IE7: select.click on open, document.mouseup on close
There are many errors for other events that mean closing (escape keypress, blur, etc.), but this is the minimum for processing the script when the user presses the select button and then clicks on the document area.
Hope this helps!