Have you got your events set up properly?
In main, somewhere after window create, something like this.
sf::Event event;
while (window.PollEvent(event))
{
switch(event.Type)
{
case sf::Event::Closed:
return EXIT_SUCCESS;
break;
case sf::Event::KeyPressed:
if (event.Key.Code == sf::Keyboard::Escape)
return EXIT_SUCCESS;
break;
}
}
Or returning from the programs execution window, window.Close().