Fix write quit bugs.