Make the disconnect event more reliable. Need to clean this up more for v1.8.0.

Possibly resolves #69.