You can set that up in VSCode settings:
- Setting 1: Terminal -> Integrated -> Enable Persistent Sessions: turn it on
- Setting 2: Terminal -> Integrated -> Persistent Session Revive Process: set it to
onExitAndWindowClose

You can set that up in VSCode settings:
onExitAndWindowClose