You might want to install and configure a good firewall app to control when your text messaging does or doesn't have any online connectivity. I'm suggesting you try NetGuard, it has a ample feature set, actively developed and supported, and it's Open Source (so no ties to business interests).
https://play.google.com/store/apps/details?id=eu.faircode.netguard&hl=en_US&gl=US
A firewall app lets you choose what apps can and cannot receive any WiFi and any cellular connectivity. In this instance, you block your text messaging app from any WiFi or cellular access when you don't want any SMS messages to come through, and allow the app access when you do. It's not the most elegant solution as you need to use the NetGuard app each time you want to enable or disable text messaging but I'm not aware of any kind of simple on/off toggle just for texting.
(Something to keep in mind is non-root firewall apps utilize an internal, local-only VPN service to do their filtering. Emphasize this is a local VPN background service, not one that uses any third-party, online server. But the issue is if you do use a conventional VPN service, this isn't an option as you can only have one VPN service running on your phone so it's a matter of one or the other.)
But a better option might be to just go into your Settings menu and turn off Notifications for your text messaging app. That way you're still receiving incoming messages but its not being popping up any notifications to bother you. You can just start up your text messaging app whenever you want to check any new messages whether you've enabled the app's Notifications or just leave it disabled.
Just curious about a more specific time frame when you refer to 'temporarily'. Is that a matter of just overnight, or something like every two or three days? People sending you messages might get worried if they don't hear back from you promptly.