You could use the sign-out button. Right mouse click on the form, Add widget, Authentication, Sign-out button or from the toolbar Authentication, Sign-out button
See documentation:
https://docs.mendix.com/refguide6/sign-out-button
Also to learn more about Mendix:
With javascript
mx.logout()