Custom query on a terminated workflow returns error

reposted here Calling Query Method on a Terminated Workflow Throws Exception