Added Event handling

Added Event loop and simple close event for testing