From the provided snippet I can see you are attaching the Command to the Close event and in order to cancel it you have to use PreviewClose:
Please give it a try and let me know if you have any further issues or concerns.
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin
, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.