Make connect event implement cancellable, closes #338