Cancel write thread on timeout