In this sense, you don't log out of MetaMask, but you can lock the application, so that you'll have to re-enter your password or biometrics to log back in. Here you can set a timer in minutes after which the wallet will be locked. Please note: you can also add an extra layer of security by adding a hardware wallet.