You can remove these lines i think
[pascal]DXDrawGame.Finalize;
RestoreWindow;[/pascal]