Fix #61 causing a race condition

The buffer thread now waits on the *intent* to stop the recording (i.e. the
internal state) instead of using the external state information.