The best MVVM solution is to remove the window chrome (close button etc) and to provide explicit close and cancel buttons which you can bind to commands in the view-model.
To handle actually closing the window, use an attached behavior, as outlined in the accepted answer to this question - How should the ViewModel close the form?