-snip-
bitcoin-cli does not prompt you to re-enter your password when doing sensitive operations like signing a transaction (unlike the GUI version of Bitcoin Core).
To be fair, when using
walletpassphrase command, the user is free to set how long the wallet should be unlocked.
If not prompting to re-enter the passphrase is the issue, the user should at least set just enough seconds for his operation.
In the GUI, it's automatically done so it'll be locked just after finishing what it needs to do.