[PAINTSEG] Improve behaviour when closing and reopening an image