Here is the code that is causing the bug:

////////////////////////////////////////////////////////////////////

var video_mode = 7; // 800x600 pixels
var video_depth = 32; // 32 bit mode
var x1;
var y1;

////////////////////////////////////////////////////////////////////

bmap mouse_pcx = <mouse.pcx>; // bitmap used for the mouse pointer
bmap main_pcx = <main.pcx>; // main panel
bmap quitclicked_pcx = <quitclicked.pcx>;
bmap quitnormal_pcx = <quitnormal.pcx>;
bmap quitover_pcx = <quitover.pcx>;

////////////////////////////////////////////////////////////////////

string work05_wmb = <work05.wmb>;

////////////////////////////////////////////////////////////////////

function main()
{
level_load (work05_wmb);
mouse_map = mouse_pcx;
mouse_mode = 2;
while (1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;

x1 = mouse_pos.x;
y1 = mouse_pos.y
wait (1);
}
}

function quit_program()
{
sleep (3);
exit;
}

//////////////////////////////////////////////////////////////////////

panel main_pan
{
bmap = main_pcx;
pos_x = x1;
pos_y = y1;
button = 250, 200, quitclicked_pcx, quitnormal_pcx, quitover_pcx, quit_program, null, null;
flags = overlay, refresh, visible;
}