code: func (m *model) tearDownFolderLocked(cfg config.FolderConfiguration, err error) {
  	// Stop the services running for this folder and wait for them to finish
  	// stopping to prevent races on restart.
  	tokens := m.folderRunnerTokens[cfg.ID]
  
  	m.fmut.Unlock()
  
  	// Close connections to affected devices
  	// Must happen before stopping the folder service to abort ongoing
  	// transmissions and thus allow timely service termination.
  	m.closeConns(cfg.DeviceIDs(), err)
  
  	for _, id := range tokens {
  		m.RemoveAndWait(id, 0)
  	}
  
  	m.fmut.Lock()
  
  	// Clean up our config maps
  	delete(m.folderCfgs, cfg.ID)
  	delete(m.folderFiles, cfg.ID)
  	delete(m.folderIgnores, cfg.ID)
  	delete(m.folderRunners, cfg.ID)
  	delete(m.folderRunnerTokens, cfg.ID)
  }
docs: // Need to hold lock on m.fmut when calling this.