Fixed closing of transport before last message was delivered