Are you sure the program is crashing and not just exiting by hitting your call to window->close()? The SFML documentation on pollEvent() says
This function is not blocking: if there's no pending event then it will return false and leave event unmodified
You are treating the event as if it was filled with something even though it might not have been. You might be reading an uninitialized event.type variable leading to undefined behavior. pollEvent() should be used in a while loop like this
sf::Event event;
while (window.pollEvent(event))
{
// process your event...
}