Refactor connection termination.

Take advantage of Tulip's new cancellation model to simplify timeout
handling.