Simplified disconnect() function. Removed unecessary try-catch blocks.