If your organization requires users to share a common email alias, you can define a list of organization-wide addresses for each user profile. Organization-wide addresses define a common email address that a user profile can use. When sending email from Salesforce, users with these profiles can choose a different From address than the email address they have defined. Replies are delivered to the organization-wide address.
For example, assume your organization has several users under a single Support Profile. A Support Profile can be associated with an email address called email@example.com and a Display Name of Acme Support. When Support Profile users send an outbound email through Salesforce, they can choose to have their From address appear as firstname.lastname@example.org instead of their own Salesforce email address.
The highlighted sections in the following image represents the changes to the From address and Display Name that the recipient of an email might see:
After an organization-wide address is verified, it is available as a From address when sending an email or an email alert.
You can do this using nothing but configuration via the Process Builder.
Step 1: Create Timer Field
On the Case object, create a date time field with no default value.
Step 2: Create Process 1
In Process Builder, on the Email Message object, when the message is outgoing, update the parent case's Status to Waiting on Customer, and the Date Time field to the current time. If you're using Email-to-Case, you can also change the Status back to Working when an incoming message comes back from the customer.
Step 3: Create Process 2
In the Process Builder, on the Case object, when the Status is Waiting on Customer, set a delayed trigger for 48 hours after the date/time field from the first step, then set the Status to Closed.
You can do the same thing with regular Workflow Rules as well, the design would be nearly identical. Finally, if you really wanted to do it with code, you'd need a scheduled class that runs hourly to find cases to close. I'd recommend avoiding this path if you can help it.