Async client wait till write completes

I am using an async client to write some data. However, after executing some write commands and immediately closing AsyncClient via close() method I’m catching an exception in WriteListener saying:

com.aerospike.client.AerospikeException: java.nio.channels.ClosedByInterruptException
        at com.aerospike.client.async.SelectorManager.processKey(
        at com.aerospike.client.async.SelectorManager.runCommands(
Caused by: java.nio.channels.ClosedByInterruptException
        at java.nio.channels.spi.AbstractInterruptibleChannel.end(
        at com.aerospike.client.async.AsyncConnection.write(
        at com.aerospike.client.async.AsyncCommand.write(
        at com.aerospike.client.async.SelectorManager.processKey(
        ... 2 more

The data, supposed to be written, is missing. How should i handle WriteListener’s result to wait write command’s completion before I try to close the client?