Withdraw all tokens remaining in smart contract

Hi all, :wave:

I make a simple contract and play with it on the testnet, I create a token (JDR) and a smart contract, i send my token on smart contract, i set a start and an end to the contract, when it ends I have JDR tokens lefts on the smart contract, how can I withdraw all the remaining tokens on the smart contract?
and how people can get their tokens automatically ? because when the contract end, they have to withdraw manually their tokens.

:1234: Code to reproduce

Smart contract

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.1/contracts/crowdsale/Crowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.1/contracts/crowdsale/validation/TimedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.1/contracts/crowdsale/distribution/FinalizableCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.1/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol";

contract SimpleCrowdsale is Crowdsale, TimedCrowdsale, FinalizableCrowdsale, PostDeliveryCrowdsale  {
    constructor (
        uint256 rate,
        address payable wallet,
        IERC20 token,
         uint openingTime,  
        uint closingTime      
    )
        public
        Crowdsale(rate, wallet, token)
        TimedCrowdsale(openingTime, closingTime)
        FinalizableCrowdsale()
    {
    }
}

Token contract

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract SimpleTokens ERC20 {
    constructor() ERC20("SimpleToken", "JDR") {
        _mint(msg.sender, 10000000000 * 10 ** decimals());
    }
}

:computer: Environment

I use Remix for all the deployement.

Thanks for the answers !

We no longer offer the Crowdsale contracts so support is limited.

You would need to add a custom function to do this.

You're using PostDeliveryCrowdsale. This is what is causing the tokens to need to be withdrawn manually.

Hi, thanks for your answer,

so I can't make the withdraw automaticaly if I use the PostDeliveryCrowdsale ?

"You would need to add a custom function to do this."

I saw the withdraw function but I think it's only work on Solidity 8.0, do you know if I can use this on 5.0 ?

Sorry you will need to try and see what errors you run into.

Automatic withdraw is not possible out of the box with PostDeliveryCrowdsale.