ROOT (TApplication) crash on exist when using with SFML

Hi all,
I was trying to use ROOT with SFML to display statistics while I do other GUI stuff. So I ended up with the following code.

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

#include <TApplication.h>


int main(int argc, char** argv)
{
        sf::RenderWindow window(sf::VideoMode(1200, 720), "SFML with ROOT");

        TApplication root_app("rootapp", &argc, argv);
        gStyle->SetCanvasPreferGL(true);

        bool running = true;
        while(running) {
                sf::Event event;
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)
                                running = false;
                }

                window.clear(sf::Color(198, 209, 244));

                window.display();
        }
}

(Compile with c++ main.cpp $(root-config --glibs --cflags) -lsfml-window -lsfml-system -o main)

The application starts normally. But when I closed the SFML window and exits the application. A segfault is generated. Am I doing anything wrong?

Where do you process the ROOT events (where do you call gSystem->ProcessEvents())?