fixed bug that prevented stream thread from ending