Remove document when closing the last view.  Should resolve Bug #1292.