Removed trailing spaces and minor consistency fixes.
Improved indentation consistency and changed it to two spaces.
Reduced line breaks and minor code format changes.
Added closeCallback support.
Refactored close events.