n8/draft_extension — pull request #2 by macu (2013-03-27 20:30:41+00:00)
Title: Close the popup window only after the callbacks are done

Clicking "New Document" or "Previous Document" closed the popup but then nothing happened. I looked on the web store and others were saying the same.

Playing with the code I found that [the callback from line 38 of popup.js](https://github.com/n8/draft_extension/blob/b25504ad28bd0f7acead1c1cbbd93f711922a12a/popup.js#L38) was never getting called. Figures that in some cases the window was closed too soon, destroying the popup and its script so the callbacks were cancelled.

Closing the window from end points within the callbacks fixed the problem for me.