Closing prepared statements in generateExport