Try to close instead of end when connection is stuck in event loop