On Windows, I had to delete folder "C:\Users\\AppData\Local\RStudio-Desktop" to fix this issue.
Check your RStudio -> Preferences. Tab General, this option:
Probably, after running your code you have huge variables in memory and RStudio tries to save your workspace and it takes time.
Posting this answer for someone still looking for a solution. Task Manager >Processes >Apps >RStudio> right click >End Task. This is for windows and for Mac,force quit method should probably work! Thanks!