stop read and write thread before destructing objects