Bug causing callback being invoked before actually closing output stream fixed.