fix a problem in ShadowStream.end()