Bug: Crash when quitting application with fullscreen window

The same code works fine when using non-fullscreen modes, or when using desktop fullscreen.
Unfortunately on multiple machines (one, eeepc with intel graphics chipset, two, desktop with ati 5800) and under XP,
using mingw,
SDL2 crashes when exiting fullscreen mode.
There’s no problems with the code, and neither of the machines have problems with (non-desktop) fullscreen games.

The code below is just some simple instantiation for demonstration purposes, no texture displays etc. In my real OO code with textures displayed, it does exactly the same thing. Changing the resolution size makes no difference.

The problem may be specific to mingw + SDL2,
or it may be specific to XP + SDL2. Or a combination.

//Using SDL, SDL_image, standard IO, and strings
#include “SDL.h”
#include <stdio.h>
#include

//Screen dimension constants
const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 600;

//Starts up SDL and creates window
bool init();

//Frees media and shuts down SDL
void close();

//The window we’ll be rendering to
SDL_Window* gWindow = NULL;

//The window renderer
SDL_Renderer* gRenderer = NULL;

bool init()
{
//Initialization flag
bool success = true;

//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
	printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
	success = false;
}
else
{
	//Set texture filtering to linear
	if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) )
	{
		printf( "Warning: Linear texture filtering not enabled!" );
	}

	//Create window
	gWindow = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN|SDL_WINDOW_FULLSCREEN );
	if( gWindow == NULL )
	{
		printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
		success = false;
	}
	else
	{
		//Create renderer for window
		gRenderer = SDL_CreateRenderer( gWindow, -1, SDL_RENDERER_ACCELERATED );
		if( gRenderer == NULL )
		{
			printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
			success = false;
		}
		else
		{
			//Initialize renderer color
			SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );

		}
	}
}

return success;

}

void close()
{

//Destroy window	
SDL_DestroyRenderer( gRenderer );
SDL_DestroyWindow( gWindow );
gWindow = NULL;
gRenderer = NULL;

//Quit SDL subsystems
SDL_Quit();

}

int main( int argc, char* args[] )
{
//Start up SDL and create window
if( !init() )
{
printf( “Failed to initialize!\n” );
}
else
{
SDL_Delay(2000);
}

//Free resources and close SDL
close();

return 0;

}