Fixed several issues in job cancellation.