Fixed async close issue and memory leak