Fixed Memory Leak

Fixed memory leak on query export