Dobré ráno.
How are you trying to close the page?
I expect you are using a combination of server-side and client-side, so the MySQL should be completed before you get anywhere near the client-side.
Code:
<?

// DO YOUR INSERT/UPDATE/DELETE, WHATEVER UP HERE

// NOW CLOSE THE WINDOW
echo '<script> window.close(); </script>';

?>
Perhaps seeing the code will help.