Implement disconnect function.
Fix bug in sending PONG message caused by not using str function when calling write.