Add callback for server stopped event. Add waitFlushingData param to
disconnect method of client.