Since it takes long time, I want to close bitcoin core and continue later.
Will it continue from where it stopped, or do one must do the whole scan in one session?
You can use the rescanblockchain
command/RPC to rescan in stages. Simply provide a start height and stop height, then next time, start from the previous place you left off. You can continue this until you've rescanned the entire chain.
You can use the getwalletinfo
RPC to see the current rescan progress too. If the wallet is already scanning, you can use this to estimate which block height it is up to, and then resume from there using rescanblockchain
.