This is a 2 part Rollup. The first part captures the number activities on an opportunity. The second part makes use of workflow rules to capture the number of activities completed before a deal was closed. Take note if an opportunity is re-opened and closed the number of activities before closed date field will change to match the number of activities field.

Step 1. - Create a field to hold the number activities completed, and a field to hold the number of activities completed before deal closed.

Step 2. - Create a Rollup to the opportunity object, Select number of activities field as target field

Step 3. - Select Task as child object, and Deleted as source field, Select Count as Rollup Type

Step 4. - Create a workflow on the opportunity object

Step 5. - Name the rule, set Evaluation Criteria to created, and everytime its edited

Step 6. - Change the Rule Criteria to formula evaluates true, the formula should be set to

(IsClosed  = False) &&
ISCHANGED(Number_of_Activities__c) ||

Step 7. - Create a workflow action, set it to use a formula to set the new value, in the formula field put the A.P.I. name of your rollup target field

Step 8. - Make sure to activate your workflow rule! After this is done Your Rollup should be up and running!