I am writing a program for a company and would like to limit how many
users can use this program at one time.

IE if they have a 3 user licence when the 4th user tries to log in it wont let them.

I have no idea how to accomplish this, does anyone have any bright ideas?

There would have to be some sort of central authority which all users could connect to. This could be a database which tracks users as they log in/log out of the app, or it could be as simple as a shared folder in which a file is created/deleted at app start/close. If, for example, you have only three licences then if there are three files already in the folder then the app would either close, or pause while a timer periodically rechecks the folder until a licence is available. In situations like this I have found it useful for the paused users to be shown who else is currently using and how long they have been using (in case a user has walked away from a running app).