This page uses the proposed CloseWatcher API to allow closing the sidebar when you use the Esc key, or Android back button.

Be sure you are using Chrome Canary v90.0.4429.0 or later, with the Experimental Web Platform Features flag turned on in chrome://flags.

Demo source on Glitch