Fix the assert at shutdown: event server construction/destruction order and leak fix