Try JbpmContext.getGraphSession().deleteProcessInstance(). It will take care of everything. Variables, task instances, subprocess instances and logs. Make sure you use a recent version of jBPM. In earlier versions some corner cases were not covered.
Deleting a process instance is a rather complex operation. You'd be better off scheduling a periodic task which queried for and deleted ended process instances. Otherwise the deletion will disrupt your online operation.