Leave the server
Enter disconnect in the CS2 console and press Enter. It closes the current server connection and returns you to the menu. To close the game entirely, use its quit option.
Check the match status
After leaving Competitive, check whether CS2 offers a reconnect option. Steam says abandoning an unfinished Competitive match or failing to return in time can cause a cooldown. Using the console to disconnect follows the same condition.
Test it in practice
If you want a convenient exit for local practice, test disconnect there first. Before assigning it to a key, save the existing binding and choose a key you will not hit during movement.