Cleaner implementation of guard files for indexing.
Rebuild now uses the clear task between stopping the daemon and indexing.

This ensures TS index locking files are removed as well. Should help situations like in #778.