Added exception catching for disconnect()