Send the disconnect event after doing the disconnection logic

fixes #39