There are some functions that are called on connect and on disconnect. In the disconnect you can cause a WDT reset. See the 2 links below.