catch exceptions if thread is interrupted