add proper disconnecting implementation and custom window exit listener