Detect tab close, purge doc from docs list and emit docClose event.