base_update: fix races in terminate flag

Move writing and reading the terminate flag within the pthread mutex
calls, remove the unnecessary volatile modifier and add an additional
flag check before calling pthread_cond_timedwait(). This fixes a data
race between the main and the base_update thread introduced in 8fc777c
"base_update: update items in store at bases".

This was noticable by a hang of BASE_UPDATE_INTERVAL seconds after
calling quit immediately after startup if compiled with optimization
turned on.
base_update: bail out if clock_gettime() fails

In the unlikely case the call actually failed, the base_update thread
would be stuck in a continuous loop. It's better to log an error message
and bail out.