Are you using persistence? If so, I think the process is deleted from session, and you have to use the audit tables.
http://docs.jboss.org/jbpm/v5.1/userguide/ch07.html#d0e2836
If you are not using persistence, I think you could get the ProcessInstance instance before it finishes, and then get the variable:
WorkflowProcessInstance pi = (WorkflowProcessInstance)session.getProcessInstance(processInstanceId);
...
pi.getVariable("var")