Fix endPreview race condition