title: Handle close event of the window in Swift
body: <p>How to handle close event of the window using swift, for example, to ask "Are you sure you want to close the form?"</p>
  
  <p><a href="https://i.stack.imgur.com/0NgVa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0NgVa.png" alt="enter image description here"></a></p>
  
  <p>The form will be closed in the case "yes" and not closed in the case "no". Showing message box is not a problem for me.</p>
  
  <p>viewWillDisappear() works for minimizing also, but I need only close event.</p>
  
  <p>Thanks.</p>