replace writer.Close() with write.close()

1. remove writer.Lock()
2. call transactionCleanup() in writer.close()