Make disconnect really work (and add signal handling on Unix)