Make hanging detection also handle exception cases