How to get the amount generated by app before deleting it from iTunes Connect
The amount earned will be transferred into your bank account automatically without you having to do anything. However, when that happens will depend on a number of factors, such as whether you still have any others apps on the App Store and therefore still generate an income from them, etc.

If you have some concerns, or wish to just generally discuss this with someone, then contact the Apple Developer Program Support number for your country. You can find it at: https://developer.apple.com/contact/phone/.