Fix logbuf issues

This fixes a tailer leak, a race on the close flag, as well as a logical race that could cause some lines at the end of a log to not be read.