properly disconnect when main form is closed