Sure, this is possible. What you'd need to do is replace the normal toolbar (which you can find in index.html, see below) with your own toolbar. In this toolbar, you'd have to add a custom widget which triggers a Microflow, which then performs whatever actions you want. If everything goes well, you can then log the user out using a java action.
<div id="toolbar"> <div class="MxClient_toolbar" id="MxClient_toolbar" dojoType="mendix.widget.MxToolbar"></div> </div>
Note that this sounds easier than it is ;) You'd need to do some digging into custom widgets and how java actions work.