Fix errors caused by destroying a viewer while pages are loading

Some errors were being thrown when promises were resolved after destroying a viewer (while pages were still loading). This fixes that issue.