fixed bug when closing and reopening chat plugin (issue #191)