code: func (w *SegmentWAL) Close() error {
  	// Make sure you can call Close() multiple times.
  	select {
  	case <-w.stopc:
  		return nil // Already closed.
  	default:
  	}
  
  	close(w.stopc)
  	<-w.donec
  
  	w.mtx.Lock()
  	defer w.mtx.Unlock()
  
  	if err := w.sync(); err != nil {
  		return err
  	}
  	// On opening, a WAL must be fully consumed once. Afterwards
  	// only the current segment will still be open.
  	if hf := w.head(); hf != nil {
  		if err := hf.Close(); err != nil {
  			return errors.Wrapf(err, "closing WAL head %s", hf.Name())
  		}
  	}
  
  	return errors.Wrapf(w.dirFile.Close(), "closing WAL dir %s", w.dirFile.Name())
  }
docs: // Close syncs all data and closes the underlying resources.