Writing the doc creates a race condition.

If get_buf returns before the beforeChangedEvent handler fires the
runLater the file is locked forever.