Move port cycling to Connection.onClose

This fixes #36.