close stream when all chunks receieved, fix #1