Fix issue with premature connection close on export