# confirm exit of Smart Client

**URL:** <https://forum.servoy.com/t/confirm-exit-of-smart-client/18766>\
**Category:** Classic Servoy\
**Created:** [March 8, 2016, 8:30pm UTC](https://forum.servoy.com/t/confirm-exit-of-smart-client/18766 "2016-03-08T20:30:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![t-rob](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@t-rob](https://forum.servoy.com/u/t-rob)\
**Post date:** [March 8, 2016, 8:30pm UTC](https://forum.servoy.com/t/confirm-exit-of-smart-client/18766/1 "2016-03-08T20:30:22Z")

</div>

I have code that confirms the user wants to exit the Smart Client when they click a Logout button. Is there a way to create a user confirmation when they simply click the “X” (in Windows) to close the main window of the application? Or maybe there is a way to disable the “X”?

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [March 8, 2016, 9:20pm UTC](https://forum.servoy.com/t/confirm-exit-of-smart-client/18766/2 "2016-03-08T21:20:44Z")

</div>

Just attach the function below to the ‘onClose’ event handler.  
You’ll find this event in the properties off the (main) solution.

```auto
/**
 * Callback method for when solution is closed, force boolean argument tells if this is a force (not stoppable) close or not.
 *
 * @param {Boolean} force if false then solution close can be stopped by returning false
 *
 * @returns {Boolean}
 */
function onSolutionClose(force) {
	var _sAnswer = 'OK';
	
	if(!force) {
		_sAnswer = plugins.dialogs.showQuestionDialog('Exit application','Are you sure you want to exit the application?', 'Cancel', 'OK');
	}
	
	return (_sAnswer == 'OK')
}

```

---

<div class="post-metadata">

**Author:** ![t-rob](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@t-rob](https://forum.servoy.com/u/t-rob)\
**Post date:** [March 9, 2016, 3:39am UTC](https://forum.servoy.com/t/confirm-exit-of-smart-client/18766/3 "2016-03-09T03:39:58Z")

</div>

Perfect! Works great. Thank you!!
