Fix #4151 Mousing off close button to cancel close command 

Please review: Fix bug #4151 

 I add a new variable to check if the mouse is inside the button. Otherwise, it just cancels the event