Fix async writing and cleanup