{
if(_connectionEndpoint != null && _connectionEndpoint.getLocalState() == EndpointState.CLOSED && !_isCloseSent)
{
if(!hasSendableMessages(null))
{
Close close = new Close();
ErrorCondition localError = _connectionEndpoint.getCondition();
if( localError.getCondition() !=null )
{
close.setError(localError);
}
_isCloseSent = true;
writeFrame(0, close, null, null);