Freeing the memory reserved by the event in the main loop