Fix #4151 Mousing off close button to cancel close command 

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