Implemented Events

Added the "close button" event and it now works great.