585 add close event to x button

closes #585 
wow, that's a really good way to do this!