Added code to free the out set when terminating the statement