1. don't ignore the pinned post in this forum about posting an OBS Studio Log from a Recording and/or Streaming session (15-30 seconds or longer, please)
2. Also, follow directions - like the BIG RED warning in OBS about NOT recording to MP4 format. remux if need be, but don't record to a recording unsafe format... just silly
real-time video encoding is VERY computationally demanding. I recommend monitoring hardware resource (CPU, GPU, RAM, Disk I/O, etc) utilization [for ex. using Task manager’s Performance tab and/or Resource Monitor] to see if your system is being maxed out with your settings
https://obsproject.com/wiki/General-Performance-and-Encoding-Issues and
https://obsproject.com/wiki/GPU-overload-issues
Also, if applicable, laptop CPU models with a 'U' are the worst fit for real-time video encoding as the U means ultra-low power for battery life (opposite of performance) and often thermally throttled, so don't expect much without investing time to become somewhat expert in Operating System and OBS Studio optimizations for an under-powered system.
lastly, if an older computer, and Disk I/O bottlenecks exist, then recording to a motherboard connected (not USB) SSD instead of HDD will probably help. Personally, I removed HDD as OS/primary data drives years ago. I use HDD for data archiving. Also, Beware security software interfering with Recording (not common but has/does happen). I mention this based on title of OBS taking a while to stop recording. that sounds like an overwhelmed computer trying to catch up.... which could be disk or other factor