make sure to cleanup everything if a job raises an exception

Hi,

Just in case you are maintaining this branch...

Previous code leads to throw timeout errors at random places if:
- the job fails
- the job thread is re-used for somthing else 

New master looks good but I've checked very quickly

By,
Thomas