adding quit function

we need to call quit() before we terminate a reader because it will try to write to the outchan in the reader's goroutine.