Add close after flush when connection state == 'opening'. Closes #13.