Solution for customers
Set cookie lifetime to
0 ("session") in Stores > Configuration > General > Web:
He should be redirected to the login page if he reopens the browser.
If you don't want to allow not logged in customers to view any page besides the login page at all, you'll need an extension that can restrict access to the catalog.
Solution for admin
In Magento 2.1 this is already the case for the admin area: session cookies are set with "session" lifetime.
The relevant code is in
* Set session cookie lifetime to session duration
* @return $this
protected function configureCookieLifetime()
Without rewriting the class, you can achieve the same in Magento 2.0 with a plugin for this class and the following interceptor method:
public function beforeSetCookieLifetime()
return [0, null];
This way the cookie lifetime is always set to
0 (i.e. "session"), regardless what's the configured value.