Catch exceptions if thread is interrupted (fixed issue #187)