Prevent duplicate write error when closing a failed job

Improve exception handling for failing jobs
Abort closing writes for failing job which resulted in duplicate errors
fix #190