Replace CloseHandle with delete and most instances of INVALID_HANDLE with null
Updated with new Event syntax.