> For the complete documentation index, see [llms.txt](https://codex.irrevocable.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codex.irrevocable.dev/sdk-reference/envoker/terminate-and-withdraw.md).

# Terminate & Withdraw

This function serves as an emergency measure to retrieve deposited ERC20 rewards from your Kinora Escrow Instance Contract.&#x20;

Upon activation of this function, your Quest will transition to a Closed status. This cessation prohibits new player entries and halts ongoing milestone completions for existing participants.&#x20;

{% code overflow="wrap" fullWidth="true" %}

```typescript
const {txHash, error, errorMessage } = await newEnvoker.terminateQuestAndWithdraw(
    1,
);
```

{% endcode %}

### Terminate & Withdraw Props

{% code overflow="wrap" fullWidth="true" %}

```typescript
/* The Quest Id to close. If you need to find the Quest Id from the Lens Publication Id, you can call getQuestIdFromPublication from the Helpers functions or call getQuestIdFromLensData directly to the KinoraQuestData contract. */
questId: number;

/* (Optional) Existing Kinora Escrow Contract from a previously  Factory instantiation. */
kinoraEscrowContract?: `0x${string}`;

/* (Optional) Wallet instance for Polygon Network. If you have passed the wallet object to the constructor, it is not necessary here. */
wallet?: ethers.Wallet;
```

{% endcode %}

### Response Object

{% code overflow="wrap" fullWidth="true" %}

```typescript
/* Transaction hash for Quest termination. */
txHash?: string;

/* Boolean to indicate whether an error was encountered during termination. */
error: boolean;

/* Message of the encountered error. */
errorMessage?: string;
```

{% endcode %}
