Fix fd leak on export query cancel